BernoulliNB
public class BernoulliNB
Bernoulli naive bayes classifier.
Bernoulli naive bayes classifier used to classify discrete binary features.
Reference: “Bernoulli Naive bayes”
-
Additive smoothing parameter.
Declaration
Swift
public var alpha: Float -
The prior log probability for each class.
Declaration
Swift
public var classLogPrior: Tensor<Float> -
Log probability of each word.
Declaration
Swift
public var featureLogProb: Tensor<Float> -
Unique classes in target value set.
Declaration
Swift
public var classes: Tensor<Int32> -
Tensor contains the index of class in classes.
Declaration
Swift
public var indices: Tensor<Int32> -
Create a bernoulli naive model.
Declaration
Swift
public init( alpha: Float = 1.0 )Parameters
alphaAdditive smoothing parameter, default to
1.0. -
Fit a bernoulli naive bayes classifier model.
Declaration
Swift
public func fit(data: Tensor<Float>, labels: Tensor<Int32>)Parameters
dataTraining data with shape
[sample count, feature count].labelsTarget value with shape
[sample count]. -
Returns log-probability estimates for the input data.
Declaration
Swift
public func predictLogProba(data: Tensor<Float>) -> Tensor<Float>Parameters
dataInput data with shape
[sample count, feature count].Return Value
log-probability estimates for the input data.
-
Returns classification of input data.
Declaration
Swift
public func prediction(for data: Tensor<Float>) -> Tensor<Int32>Parameters
dataInput data with shape
[sample count, feature count].Return Value
classification of input data.
-
Returns mean accuracy on the given input data and labels.
Declaration
Swift
public func score(data: Tensor<Float>, labels: Tensor<Int32>) -> FloatParameters
dataSample data with shape
[sample count, feature count].labelsTarget label with shape
[sample count].Return Value
Returns the mean accuracy on the given input data and labels.
BernoulliNB Class Reference