Skip to content

Naive Bayes (NB) Classifier #14

Closed
Closed
@VolodymyrOrlov

Description

@VolodymyrOrlov

Implement Base NB classifier that doesn't make any assumptions about the underlying distribution of x.

https://scikit-learn.org/stable/modules/naive_bayes.html

We need something like this (pseudocode):

trait NBDistribution:
    
    // Fit distribution to some continuous or discrete data
    def fit(x: Matrix<T>) -> NBDistribution
    
    // prior of class k 
    def prior(k) -> T

    // conditional probability of feature j give class k
    def conditional_probability(k, j)-> T

class BaseNaiveBayes:
    
    // "Fits" NB. This method validates and remembers parameters
    def fit(distribution: NBDistribution)
    
    // Calculates likelihood of labels using stored probabilities and X. Returns vector with estimated labels
    def predict(x: Matrix<T>) -> Vector<T>

Once we have BaseNaiveBayes we can implement Gaussian Naive Bayes, Multinomial Naive Bayes and Bernoulli Naive Bayes as concrete implementations of trait NBDistribution

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions