Issue
I am having dataframe df
.
I want to compare two columns in dataframe and want to find accuracy
or percentage of rows which contain same values in both columns.
df
predicted_value actual_value
0 1
1 1
0 0
1 1
Output- 75% of values are matching between two columns in pandas dataframe.
Solution
acc = (df.predicted_value==df.actual_value).mean()
if you want to format the accuracy in percentage:
print("%.2f%%"%(acc*100))
Answered By - Salvatore Daniele Bianco
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.