Skip to content Skip to sidebar Skip to footer

Valueerror: Found Input Variables With Inconsistent Numbers Of Samples: [7111, 1778]

I also tried to reshape both the X(8889,17) and y(8889,1) but it didn't help at all: import pandas as pd import numpy as np from sklearn import preprocessing, cross_validation, nei

Solution 1:

Your problem is you're assigning the results of train_test_split incorrectly, and so you're trying to fit the model on X_train and X_test instead of what you think you're testing. Use this instead:

X_train, X_test, y_train, y_test = cross_validation.train_test_split(final_features,label_genres,test_size=0.2)

Incidentally, if you look at the number of samples that should give you a hint, as 7111 is almost exactly four times the size of 1778 (0.8 / 0.2 = 4).

Post a Comment for "Valueerror: Found Input Variables With Inconsistent Numbers Of Samples: [7111, 1778]"