yanyachen / MLmetrics

Machine Learning Evaluation Metrics
GNU General Public License v2.0
69 stars 14 forks source link

F1 score output #11

Open liliaevgeniou opened 4 years ago

liliaevgeniou commented 4 years ago

Hi, wondering how you calculated F1 score. Wikipedia says:

image

Here is how I would calculate F1 (using some dummy data), yet I get a different value using the Wikipedia version and MLmetrics version.

image

Thank you.

liliaevgeniou commented 4 years ago

I'm sorry, I figured out why this didn't work.

MLmetrics assumes "positive" is 0, and "negative" is 1. Hence one must specify that the positives are 1, or otherwise do 1-y_true and 1-y_pred.

MLmetrics::F1_Score(y_true = y_true, y_pred = y_pred, positive = 1)

or

MLmetrics::F1_Score(y_true = 1-y_true, y_pred = 1-y_pred)