Search code examples
scikit-learnclassificationmetricssklearn-pandas

classification accuracy with sklearn in percentage


I tried to calculate the accuracy score with sklearn.

a = accuracy_score(df['colA'], df2['colA'])

I works very well but i would like to have the score in percentage(%)

What kind of modification i can do please?


Solution

  • Accuracy score is the portion of samples that were correctly classified, out of the total number of samples, so it ranges from 0 to 1.

    This can be converted to a percentage by just multiplying it by 100:

        a = accuracy_score(df['colA'], df2['colA'])
        
        print("Current accuracy is {}%".format(a*100))
    

    enter image description here