NaiveBayesBase<T>
Base Classes · AiDotNet.Classification.NaiveBayes
Provides a base implementation for Naive Bayes classifiers.
Inheritance: ClassifierBase<T> → ProbabilisticClassifierBase<T> → NaiveBayesBase<T>
Implements: IGeneratedParameterRegistrar<T>
Known derived types: BernoulliNaiveBayes<T>, CategoricalNaiveBayes<T>, ComplementNaiveBayes<T>, GaussianNaiveBayes<T>, MultinomialNaiveBayes<T>
For Beginners
Naive Bayes uses probability to make predictions. It learns from training data:
- How common each class is (prior probability)
- How likely each feature value is given each class (likelihood)
Then for a new sample, it calculates: P(class|features) ∝ P(class) × P(features|class) and picks the class with the highest probability.
How It Works
Naive Bayes classifiers are probabilistic classifiers based on Bayes’ theorem with strong (naive) independence assumptions between the features. Despite these assumptions, Naive Bayes classifiers often perform very well in practice.
Properties
| Property | Summary |
|---|---|
bool SupportsParameterInitialization { get; } |
Naive Bayes models compute parameters from class statistics during training. |
Methods
| Method | Summary |
|---|---|
IFullModel<T, Matrix<T>, Vector<T>> WithParameters(Vector<T> parameters) |
|
Matrix<T> PredictLogProbabilities(Matrix<T> input) |
Predicts log-probabilities for each class (more numerically stable than probabilities). |
Matrix<T> PredictProbabilities(Matrix<T> input) |
Predicts class probabilities for each sample. |
ModelMetadata<T> GetModelMetadata() |
|
void Train(Matrix<T> x, Vector<T> y) |
Trains the Naive Bayes classifier on the provided data. |