Search code examples
pythonscikit-learnlogistic-regressionsklearn-pandas

Can accuracy_score and precision_score be equal?


I am trying to build a logistic regression model in python 3 using sklearn library.

Let's stick to below short versions going forward,

dv - dependent variable

idv - independent variable

Now I have idv1, idv2, idv3, idv4, idv5, idv6, idv7, idv8 & idv9.

Out of which idv6 to idv9 are categorical variables (idv6 & idv7 has 3 categories..where as idv8 & idv9 are boolean variables..yes or no kind of variables [0 or 1])

And dv is again a boolean variable (yes or no kind of variable).

Now, I have created a dummies for all idv6 to idv9 for the final model data...i.e idv6_c1, idv6_c2, idv_c3 and followed similar for the remaining..like idv8_c1, idv8_c2 for idv8 & idv9.

Now, after fitting the model and finding the metrics of the predicted values...

I am getting let's say accuracy_score of 76.7415479670124 % and precision_score of 76.7415479670124 %

I have calculated using sklearn.metrics.accuracy_score and sklearn.metrics.precision_score libraries.

I am wondering..is this correct or am I missing something...??

Can this happen ??...accuracy & precision to be equal to almost 13 decimals ???....I am sure...I am doing something wrong...can anyone please help me ??


Solution

  • Precision = True Positive / (True Positive + False Positive)

    Accuracy = (True Positive + True Negative) / (True Positive + False Positive + True Negative + False Negative)

    Therefore, if there are no negative predictions, these two values will be equal.