"A column-vector y was passed when a 1d array was expected" error message

Viewed 3177
from sklearn.discriminant_analysis import LinearDiscriminantAnalysis

clf = LinearDiscriminantAnalysis()
clf.fit(np.matrix(X_train), np.matrix(y_train))

but I get the error message. Specified above.

I checked the shape of y_train but it's (294,1). tried the ravel() thing but it then it's (1,294) and if I transpose it then it looks back how it did before the ravel().

X_train.shape is (294,8).

1 Answers

first, don't use np.matrix, use np.array instead, its no longer recommended to use this class.

Try this:

clf.fit(X_train, np.ravel(y_train))
Related