Machine Learning: Naive Bayes

import numpy as np
X = np.array([[-1, -1], [-2, -1], [-3, -2], [1, 1], [2, 1], [3, 2]]) ##Features
Y = np.array([1, 1, 1, 2, 2, 2]) ##Labels

from sklearn.naive_bayes import GaussianNB ##import library
clf = GaussianNB() ##Create the classifier
clf.fit(X, Y) ##Train the data

GaussianNB()
print(clf.predict([[-0.8, -1]])) ##predicting a new data after the training



Tags:

Categories:

Updated: