0
$\begingroup$

y_train.shape = (7654,1) y_test.shape = (1914,1)

mae = mean_absolute_error(y_train, y_test) gives: "ValueError: Found input variables with inconsistent numbers of samples: [7654, 1914]"

So I am trying to reshape y_train to (1,7654) and y_test to (1,1914). Would that work? I tried y_train = y_train.reshape(X.shape[1:]) but that doesn't work.

$\endgroup$
1
$\begingroup$

The issue is not the shape of your data. If you would like to calculate any kind of score for either your train or test predictions you need to compare the true labels to the respective predictions (either for the training data or the test data but not mixing these two):

y_train_pred = model.predict(X_train)
mae_train = mean_absolute_error(y_train, y_train_pred)

And correspondingly for your test data:

y_test_pred = model.predict(X_test)
mae_test = mean_absolute_error(y_test, y_test_pred)

(for the example I am assuming that your model object has been assigned to the variable model and used the predict() syntax of SKLearn here)

$\endgroup$

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.