scikits.learn.naive_bayes.GNB¶
- class scikits.learn.naive_bayes.GNB¶
Gaussian Naive Bayes (GNB)
Parameters : X : array-like, shape = [n_samples, n_features]
Training vector, where n_samples in the number of samples and n_features is the number of features.
y : array, shape = [n_samples]
Target vector relative to X
Examples
>>> import numpy as np >>> X = np.array([[-1, -1], [-2, -1], [-3, -2], [1, 1], [2, 1], [3, 2]]) >>> Y = np.array([1, 1, 1, 2, 2, 2]) >>> from scikits.learn.naive_bayes import GNB >>> clf = GNB() >>> clf.fit(X, Y) GNB() >>> print clf.predict([[-0.8, -1]]) [1]
Attributes
proba_y array, shape = nb of classes probability of each class. theta array of shape nb_class*nb_features mean of each feature for the different class sigma array of shape nb_class*nb_features variance of each feature for the different class Methods
fit(X, y) self Fit the model predict(X) array Predict using the model. predict_proba(X) array Predict the probability of each class using the model. - __init__()¶
- score(X, y)¶
Returns the mean error rate on the given test data and labels.
Parameters : X : array-like, shape = [n_samples, n_features]
Training set.
y : array-like, shape = [n_samples]
Labels for X.
Returns : z : float