Warning: This documentation is for scikits.learn version 0.6.0. — Latest stable version

Contents

Gaussian Naive BayesΒΆ

A classification example using Gaussian Naive Bayes (GNB).

Python source code: naive_bayes.py

################################################################################
# import some data to play with

# The IRIS dataset
from scikits.learn import datasets
iris = datasets.load_iris()

X = iris.data
y = iris.target

################################################################################
# GNB
from scikits.learn.naive_bayes import GNB
gnb = GNB()

y_pred = gnb.fit(X, y).predict(X)

print "Number of mislabeled points : %d" % (y != y_pred).sum()