Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bhavsarpratik/1abbfdb7686be4270970066ac175f7e3 to your computer and use it in GitHub Desktop.
Save bhavsarpratik/1abbfdb7686be4270970066ac175f7e3 to your computer and use it in GitHub Desktop.
fbeta_harmonic_mean.py
def fbeta_harmonic_mean(metric1: float, metric2: float, beta: float):
""" Return harmonic mean giving more importance to one metric
metric1: metric1 value
metric2: metric2 value
beta : The strength of metric2 versus metric1 in the F-score.
"""
beta2 = beta ** 2
denom = beta2 * metric1 + metric2
f_score = (1 + beta2) * metric1 * metric2 / denom
return f_score
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment