Search code examples
data-sciencemean-square-error

Why does the mean squared error function require variables of the same shape?


If we pass the training variable and the testing variable into the mean squared error function, then won't those variables necessarily have different shapes because of the train_test_split function? If so, then how can we use the mean_squared_error function to evaluate the accuracy of our model? If I am misunderstanding anything, then please let me know. Any help would be much appreciated.


Solution

  • If you for example look at the mean squared error in the sklearn package, read the documentation:

    sklearn.metrics.mean_squared_error(y_true, y_pred, sample_weight=None, multioutput=’uniform_average’)

    The inputs are not the training and testing variable, but the real test labels variable and the predicted test labels. These naturally have the same shape.