financial_physician
financial_physician

Reputation: 1998

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

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).

Upvotes: 2

Views: 4720

Answers (1)

Mulham Jarjanazi
Mulham Jarjanazi

Reputation: 386

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))

Upvotes: 3

Related Questions