Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

true-zero rate and F1-score #1

Open
ssssbug opened this issue May 29, 2024 · 2 comments
Open

true-zero rate and F1-score #1

ssssbug opened this issue May 29, 2024 · 2 comments

Comments

@ssssbug
Copy link

ssssbug commented May 29, 2024

Hello author, I would like to know how you implement the true-zero rate and F1-score, I wonder if you can make the code of these two public

@ZhuangDingyi
Copy link
Owner

Hi there,

It is based on their definitions:

def true_zeros(truth,pred):
    idx = truth == 0
    return np.sum(pred[idx]==0)/np.sum(idx)

def F1_SCORE(truth,pred):
    true_zeros = truth == 0
    pred_zeros = pred == 0
    precision = np.sum(pred_zeros & true_zeros ) / np.sum(pred_zeros)
    recall = np.sum(pred_zeros)/np.sum(true_zeros)
    return 2*(precision*recall)/(precision+recall)

@ssssbug
Copy link
Author

ssssbug commented May 30, 2024

Thank you very much for your reply, it was very helpful for me

Hi there,

It is based on their definitions:

def true_zeros(truth,pred):
    idx = truth == 0
    return np.sum(pred[idx]==0)/np.sum(idx)

def F1_SCORE(truth,pred):
    true_zeros = truth == 0
    pred_zeros = pred == 0
    precision = np.sum(pred_zeros & true_zeros ) / np.sum(pred_zeros)
    recall = np.sum(pred_zeros)/np.sum(true_zeros)
    return 2*(precision*recall)/(precision+recall)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants