Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Classification report for regression (sklearn)

When you try to predict if something belongs to a certain class you can use the classification report from sklearn. However, this only works when the classes are categorical.

Does anyone happen to figure out how to use the classification report from sklearn when you try to predict a value instead, like with a support vector regression machine or linear regression?

I get the following error:

ValueError: Unknown label type: (123     13.409091
760     16.593333
748     13.646667
334     13.828571)

When trying:

print("Classification report: ", classification_report(y_test, y_pred))

Here y_test is a column of a pandas DataFrame and y_pred is a numpy array. I tried converting the column into a numpy array, but then it gives the same error, but with the array.

Does any know how to make the classification work to check the auc, precision/recall and f1-score for the prediction of a value (if there is a better way than sklearn, please do not hesitate to say so.)

like image 981
nappingkid Avatar asked Aug 01 '18 14:08

nappingkid


People also ask

What is classification report in sklearn?

A Classification report is used to measure the quality of predictions from a classification algorithm. How many predictions are True and how many are False. More specifically, True Positives, False Positives, True negatives and False Negatives are used to predict the metrics of a classification report as shown below.

What is classification report in logistic regression?

It is one of the performance evaluation metrics of a classification-based machine learning model. It displays your model's precision, recall, F1 score and support. It provides a better understanding of the overall performance of our trained model.

How is classification report calculated?

The sum of true positives and true negatives divided by the total number of samples.


1 Answers

The metrics that you named (accuracy, precision, recall & f1-score) are specifically for classification problems, where the prediction can be either right or wrong.

As you want to predict values, you are dealing with a regression problem and you want your metric to tell you how close your prediction is. A good metric for this is the coefficient of determination also called r2-score.

like image 186
Owlright Avatar answered Oct 12 '22 19:10

Owlright