gaussiannbfit

Gaussian Naïve Bayes classifier.

Attention: Available only with Twin Activate commercial edition.

Syntax

parameters = gaussiannbfit(X,y)

Inputs

X
Training data.
Type: double
Dimension: vector | matrix
y
Target values.
Type: double
Dimension: vector | matrix

Outputs

parameters
Contains all the values passed to bernoulliFit method as options. Additionally it has below key-value pairs.
Type: struct
scorer
Function handle pointing to 'accuracy' function.
Type: function handle
labels
Unique labels in training data.
Type: double
Dimension: vector
prior
Probability of each class.
Type: double
Dimension: cell
params
Mean and Variance of each feature of each class.
Type: double
Dimension: matrix
n_samples
Number of rows in the training data.
Type: integer
Dimension: scalar
n_features
Number of columns in the training data.
Type: integer
Dimension: scalar

Example

Usage of gaussiannbfit

X = [
	-1 -1;
	-2 -1;
	-3 -2;
	1 1;
	3 1;
	3 2
];

y = [1, 1, 1, 2, 2, 2]';

parameters = gaussiannbfit(X, y)
parameters = struct [
  labels: [Matrix] 2 x 1
  1
  2
  params: 
  {
    [1,1] [Matrix] 1 x 2
    -2.00000  -1.33333
    [1,2] [Matrix] 1 x 2
    0.66667  0.22222
    [2,1] [Matrix] 1 x 2
    2.33333  1.33333
    [2,2] [Matrix] 1 x 2
    0.88889  0.22222
  }
  prior: 
  {
    [1,1] 0.5
    [2,1] 0.5
  }
]

Comments

Output 'parameters' should be passed as input to gaussiannbpredict function.