I know about the model = LinearRegression() print(model.score(x_test, y_test) method works just fine but I was thinking of a way to use the accuracy_score on LinearRegression and the error I'm getting is bugging me so here I go:
So, I have a data on which I've used the OrdinalEncoding i.e. my y comprises of whole numbers from 1 to 6 and what I thought of was to round the y_pred (after testing on x_test) into nearest whole numbers, converting the entire array to integers and then use accuracy_score on these two different arrays but the following error crops up, can someone please explain me why?
from sklearn.linear_model import LinearRegression
from sklearn.metrics import accuracy_score
model = LinearRegression()
model.fit(x_train, y_train)
y_pred = model.predict(x_test)
y_pred = np.round(y_pred)
y_pred = y_pred.astype(int)
y_test = np.array(y_test)
print(accuracy_score(y_pred, y_test))
gives me:
ValueError: Classification metrics can't handle a mix of multiclass and unknown targets