How to solve "ValueError: y should be a 1d array, got an array of shape (3, 5) instead." for naive Bayes?

Written by- Sharif 21700 times views

This error is caused by the fact that the data you are trying to train your model with is not formatted in a way that it can be used.

How to solve "ValueError: y should be a 1d array, got an array of shape (3, 5) instead." for naive Bayes?

The best way to solve this issue is to reshape the data so that it matches what naive Bayes expects. This can be done by calling np.reshape() on the data before making predictions.

Alternatively, you could use one of the following methods:

1) Use a method like pandas' groupby() or split-apply-combine() to get your data into a format that naive Bayes will understand;

2) Use an algorithm like random forest or k-nearest neighbors instead of naive Bayes;

3) Train your model with only one column (i.e.

Thank you for reading the article.




© aionlinecourse.com All rights reserved.