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

Precision equals Recall in run_classifier.py script run. #13

Open
Amit-GH opened this issue Apr 16, 2021 · 1 comment
Open

Precision equals Recall in run_classifier.py script run. #13

Amit-GH opened this issue Apr 16, 2021 · 1 comment

Comments

@Amit-GH
Copy link

Amit-GH commented Apr 16, 2021

I am trying to replicate the results of the paper. I ran run_classifier.py script for 7000 train-steps on imdb reviews. After every 1000 batches, we see precision, recall, accuracy, F1 score and loss printed on the terminal. For all the checkpoints, precision=recall=F1=accuracy up to all decimal points. I wonder if this has some mistake in calculation. For a binary dataset, we should not have precision=recall=accuracy.

For e.g. for ckpt-1000, I got 0.9408210 as the values for p, r, a, f1.

@Yuqi92
Copy link

Yuqi92 commented Jul 29, 2021

Hi, I think they used prec@k instead of precision:

p1, p1_op = tf.compat.v1.metrics.precision_at_k(
labels=tf.cast(label_ids, tf.int64), predictions=log_probs, k=1)

Here are the following official docs for these two:
Precision: https://www.tensorflow.org/api_docs/python/tf/compat/v1/metrics/precision
P@k: https://www.tensorflow.org/api_docs/python/tf/compat/v1/metrics/precision_at_k

Precision is the traditional precision metric we used.
I personally tried the tf.compat.v1.metrics.precision and it worked. Here is the sample code:

precision, precision_op = tf.compat.v1.metrics.precision(
            labels=label_ids, predictions=predictions, weights=None, name="precision")

The same with Recall. Finally I got precision of 0.9483 and recall of 0.9606 with training step of 2,000.

Hope this helps.

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