I started learning ML and I have some problems with evaluating / finding the accuracy of regression and classification models.
Till now I used
.score() in both cases but people told me that Its not the accuracy.
Then I tried to use this:
from sklearn.model_selection import train_test_split from sklearn.metrics import accuracy_score from sklearn.metrics import mean_squared_error var_train, var_test, res_train, res_test = train_test_split(variables, results, test_size = 0.2, random_state = 4) regression = linear_model.LinearRegression() regression.fit(var_train, res_train) input_values = [14, 2] prediction = regression.predict([input_values]) accuracy_regression = mean_squared_error(var_test, prediction)
But I always get this error:
ValueError: Found input variables with inconsistent numbers of samples: [2, 1]
I have looked all over the udemy and youtube, and a lot of people are calculating accuracy like
.score(). Then I looked all over
scikit-learn website and stackoverflow and I saw the other solution with metrics but I keep getting the same error.
What am I doing wrong?
More about the problem: