-
-
Notifications
You must be signed in to change notification settings - Fork 26.3k
Closed
Description
Description
When using GaussianNB with weights to fit, it only accepts numpy arrays and not generic python lists which is contrary to other algoithms in sklearn
Related bug/feature request: #4346
Steps/Code to Reproduce
from sklearn.naive_bayes import GaussianNB
import numpy as np
gnb = GaussianNB()
# gnb.fit([[1,2],[2,2],[1,1]],[1,2,1],[1,1,1]) # causes error here
'''
ERROR:
Traceback (most recent call last):
File "testGNBWeights.py", line 5, in <module>
gnb.fit([[1,2],[2,2],[1,1]],[1,2,1],[1,1,1]) # causes error here
File "/usr/local/lib/python2.7/dist-packages/sklearn/naive_bayes.py", line 184, in fit
sample_weight=sample_weight)
File "/usr/local/lib/python2.7/dist-packages/sklearn/naive_bayes.py", line 398, in _partial_fit
sw_i = sample_weight[y == y_i]
'''
gnb.fit([[1,2],[2,2],[1,1]],[1,2,1],np.array([1,1,1])) # this works!
Expected Results
NA
Actual Results
Error
Versions
Metadata
Metadata
Assignees
Labels
No labels