Skip to content
Advertisement

How to solve “ValueError: y should be a 1d array, got an array of shape (73584, 15) instead.”

I am new to python and machine learning. I want to fit SVM to the training sets.

JavaScript

Then I got an error: ValueError: y should be a 1d array, got an array of shape (73584, 15) instead.

JavaScript

Output:

JavaScript

So how should I fix this problem? Would appreciate a lot if any advices.


Shape of y:

Examples of label y are:

Advertisement

Answer

SVM output is, for each data point, one class. Therefore, with 73584 data points of 37 features, your target needs to be a vector of 73584 classifications, each of which is a class number. Did you one-hot encode your output? You should undo that.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement