11
Using scikit-learn 0.10
Why does the following trivial code snippet:
from sklearn.naive_bayes import *
import sklearn
from sklearn.naive_bayes import *
print sklearn.__version__
X = np.array([ [1, 1, 1, 1, 1],
[0, 0, 0, 0, 0] ])
print "X: ", X
Y = np.array([ 1, 2 ])
print "Y: ", Y
clf = BernoulliNB()
clf.fit(X, Y)
print "Prediction:", clf.predict( [0, 0, 0, 0, 0] )
Print out an answer of "1" ? Having trained the model on [0,0,0,0,0] => 2 I was expecting "2" as the answer.
And why does replacing Y with
Y = np.array([ 3, 2 ])
Give a different class "2" as an answer (the correct one) ? Isn't this just a class label?
Can someone shed some light on this?