[Solved] ValueError: shapes (4155,1445) and (4587,7) not aligned: 1445 (dim 1) != 4587 (dim 0)


Have a look at the sci-kit learn documentation for Multinomial NB.

It clearly specifies the structure of the input data while trainig model.fit() must match the structure of the input data while testing or scoring model.predict().

This means that you cannot use the same model for different dataset. The only way this is possible is that both the dataset have the same features (same number of features and in the same order as the training dataset).

In your case this is not going to work as the datasets are different which is visible from the shape of the two datasets.

Set 1 has 4587 features
Set 2 has 1445 features

Make sure the both the dataset have the same number of features and in the same order as the training set.

solved ValueError: shapes (4155,1445) and (4587,7) not aligned: 1445 (dim 1) != 4587 (dim 0)