naiveBayes

fun naiveBayes(x: Array<IntArray>, y: IntArray, model: DiscreteNaiveBayes.Model, priori: DoubleArray? = null, sigma: Double = 1.0): DiscreteNaiveBayes

Creates a naive Bayes classifier for document classification. Add-k smoothing.

Parameters

x

training samples.

y

training labels in [0, k), where k is the number of classes.

model

the generation model of naive Bayes classifier.

priori

the priori probability of each class. If null, equal probability is assume for each class.

sigma

the prior count of add-k smoothing of evidence.


fun naiveBayes(priori: DoubleArray, condprob: Array<Array<Distribution>>): NaiveBayes

Creates a general naive Bayes classifier.

Parameters

priori

the priori probability of each class.

condprob

the conditional distribution of each variable in each class. In particular, condprob[i][j] is the conditional distribution P(xj | class i).