简体   繁体   中英

Confusion matrix in linear regression

I have actual values and predicted values.

Actual: 33.3663, 38.2561, 28.6362, 35.6252

Predicted: 28.9721, 35.6161, 27.9561, 22.6272

I want to apply confusion matrix to find the accuracy.

Solution

First thing, confusion matrix is not for continuous values. AND you can also use it by converting continuous values to classes. check https://datascience.stackexchange.com/questions/46019/continuous-variable-not-supported-in-confusion-matrix


from sklearn.metrics import confusion_matrix
 
expected = [1, 1, 0, 1, 0, 0, 1, 0, 0, 0]
predicted = [1, 0, 0, 1, 0, 0, 1, 1, 1, 0]
results = confusion_matrix(expected, predicted)
print(results)

Output

[[4 2]
 [1 3]]

Reference

https://machinelearningmastery.com/confusion-matrix-machine-learning/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM