问题
I am new to the world of ML and sklearn. I tried to use GaussianNB on a dataset with X_train[2500,800]
, Y_train[2500,8]
.
from sklearn.naive_bayes import GaussianNB
clf = GaussianNB()
clf.fit(X, Y)
On running the program, it is showing
ValueError: bad input shape (2500, 8).
How do i convert Y_train[2500,8]
to Y_train[2500,1]
?
回答1:
OP is using a one hot encoder so the fit function won't work with the array @Ishant Mrinal recommends this
Y_train = np.argmax(Y_train, axis=1)
That will allow you to pass the one hot encoding into the fit function.
来源:https://stackoverflow.com/questions/45768899/sklearn-bad-input-shape-valueerror