Skip to content

Instantly share code, notes, and snippets.

@tranghaviet
Created May 1, 2017 09:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tranghaviet/400324f56fd1557ca4caa55bd11316d5 to your computer and use it in GitHub Desktop.
Save tranghaviet/400324f56fd1557ca4caa55bd11316d5 to your computer and use it in GitHub Desktop.
A GaussianNB example
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 sklearn.naive_bayes import GaussianNB
clf = GaussianNB()
clf.fit(X, Y)
print(clf.predict([[-0.8, -1]]))
clf_pf = GaussianNB()
clf_pf.partial_fit(X, Y, np.unique(Y))
print(clf_pf.predict([[-0.8, -1]]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment