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.)
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.
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.
The sum of true positives and true negatives divided by the total number of samples.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With