numpy和scikit的“未知标签类型”

时间:2018-11-17 07:49:51

标签: numpy scikit-learn

X = np.array(...,dtype=np.float64).astype(np.float)
y = np.array(...,dtype=np.float64).astype(np.float)

print(X)
[[-0.5  0. ]
 [ 0.   0. ]
 [ 0.   0. ]
 [ 0.   0. ]
 [ 0.  -3.5]
 [-3.5 -3.5]
 [-3.5 -2. ]
 [-2.   0. ]
 [ 0.   0. ]
 [ 0.  -3. ]]
print(y)
[-3.5 -3.5 -3.5 -3.5 -3.5 -2.  -3.  -3.  -3.   1. ]
(10, 2)
(10,)


from sklearn.naive_bayes import GaussianNB
clf = GaussianNB()
clf.fit(X, Y)

无论我得到什么

Traceback (most recent call last):
  File "scripts/wave-pool.py", line 174, in <module>
    clf.fit(X, y)
  File "/home/ben/.local/lib/python2.7/site-packages/sklearn/naive_bayes.py", line 192, in fit
    sample_weight=sample_weight)
  File "/home/ben/.local/lib/python2.7/site-packages/sklearn/naive_bayes.py", line 355, in _partial_fit
    if _check_partial_fit_first_call(self, classes):
  File "/home/ben/.local/lib/python2.7/site-packages/sklearn/utils/multiclass.py", line 320, in _check_partial_fit_first_call
    clf.classes_ = unique_labels(classes)
  File "/home/ben/.local/lib/python2.7/site-packages/sklearn/utils/multiclass.py", line 96, in unique_labels
    raise ValueError("Unknown label type: %s" % repr(ys))
ValueError: Unknown label type: (array([-3.5, -3. , -2. ,  1. ]),)

0 个答案:

没有答案