-1
$\begingroup$

I have two datasets train and test I did all the data cleaning on both the datasets.In my test dataset I don't have the dependant variable while in the train set I have dependent as well as independent variables. So, to make the predictions I am using my y_train which will act as my y_test and test for the independent variables.When I try to get accuracy using the confusion_matrix, I get the following error:

Error: Found input variables with inconsistent numbers of samples: [891, 418]

y_train.shape - (891,)

test.shape - (418, 9)

How do I fix this ? This is my first project and I am a beginner.

$\endgroup$
0
$\begingroup$

You are comparing your training dataset (y_train) with your test dataset (test). These datasets have different lengths (891 vs 418) meaning that you can't compare them 1:1. You need to make sure you select both your features and values to predict from the same split, so either form the training or the test dataset.

$\endgroup$
1
  • $\begingroup$ Yeah well they have already provided me with the two files one with the train sets and another with the test set, so I have to stick to those as I haven't done the split myself $\endgroup$ – Tejas Joshi Jan 21 at 6:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.