0 votes
1 view
in Machine Learning by (13.5k points)

I'm using linear_model.LinearRegression from scikit-learn as a predictive model. It works and it's perfect. I have a problem to evaluate the predicted results using the accuracy_score metric. This is my true Data :

array([1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0])

My predictive Data:

array([ 0.07094605,  0.1994941 , 0.19270157,  0.13379635, 0.04654469,

    0.09212494,  0.19952108, 0.12884365,  0.15685076, -0.01274453,

    0.32167554,  0.32167554, -0.10023553,  0.09819648, -0.06755516,

    0.25390082,  0.17248324])

My code:

accuracy_score(y_true, y_pred, normalize=False)

Error message:

ValueError: Can't handle mix of binary and continuous target

Help ? Thank you.

1 Answer

0 votes
by (33.2k points)

Linear regression is a very poor classifier because it can’t classify two classes clearly. So It is not recommended to use for classification problems.

You can fix this error by using the following code:

accuracy_score(y_true, y_pred.round(), normalize=False)

If you wish to learn more about Machine Learning, then check out this Machine Learning Tutorial for more insights.

Hope this answer helps.

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...