All problems

F1 Score From Precision and Recall Directly

easyPythonML Metrics

Vendors keep pitching Larkspur Mail ready-made spam filters, and their one-page summaries are thinner than the team would like. A summary gives two figures for the spam class and nothing else: a precision and a recall. No confusion matrix, no test set size, no raw counts - vendors consider those commercially sensitive.

Larkspur's internal scorecard is F1, so procurement needs every vendor scored on the same scale as the filters built in-house, using only what each vendor was willing to hand over.

Task: Print the vendor filter's F1 score, as a single number rounded to 4 decimals. Round once, at the end.

Input

The first line holds the vendor's precision for the spam class, a decimal between 0 and 1. The second line holds the recall, in the same form. They are never both zero.

Output

One line holding the F1 score, rounded to 4 decimals and printed the way Python prints a float - 0.6667, and 0.5 rather than 0.5000.

Example:

Input:
0.75
0.6

Output:
0.6667

Sign in to solve this problem

Reading problems is free for everyone — solving them (Run, Submit, and tracking what you've solved) needs an account.

Sign in

Discussion

Sign in to join the discussion — reading is open to everyone.

Loading comments…