Skip to content

Commit

Permalink
deprecated f- & g-measures, changed method of calculating f1-score
Browse files Browse the repository at this point in the history
  • Loading branch information
chrislit committed Nov 20, 2018
1 parent 414f9c7 commit f3182eb
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
2 changes: 1 addition & 1 deletion abydos/stats/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@
>>> ct = ConfusionTable(120, 60, 20, 30)
>>> ct.f1_score()
0.8275862068965516
0.8275862068965518
>>> ct.mcc()
0.5367450401216932
>>> ct.specificity()
Expand Down
27 changes: 21 additions & 6 deletions abydos/stats/_confusion_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@

import math

from deprecation import deprecated

from ._mean import (
aghmean,
agmean,
Expand All @@ -58,6 +60,7 @@
qmean,
seiffert_mean,
)
from .. import __version__

__all__ = ['ConfusionTable']

Expand Down Expand Up @@ -1318,12 +1321,12 @@ def fbeta_score(self, beta=1.0):
0.8565371024734982
"""
if beta <= 0:
if beta <= 0.0:
raise AttributeError('Beta must be a positive real value.')
precision = self.precision()
recall = self.recall()
return (
(1 + beta ** 2)
(1.0 + beta ** 2)
* precision
* recall
/ ((beta ** 2 * precision) + recall)
Expand Down Expand Up @@ -1373,7 +1376,7 @@ def fhalf_score(self):
"""
return self.fbeta_score(0.5)

def e_score(self, beta=1):
def e_score(self, beta=1.0):
r"""Return :math:`E`-score.
This is Van Rijsbergen's effectiveness measure:
Expand All @@ -1398,7 +1401,7 @@ def e_score(self, beta=1):
0.17241379310344818
"""
return 1 - self.fbeta_score(beta)
return 1.0 - self.fbeta_score(beta)

def f1_score(self):
r"""Return :math:`F_{1}` score.
Expand All @@ -1417,11 +1420,17 @@ def f1_score(self):
-------
>>> ct = ConfusionTable(120, 60, 20, 30)
>>> ct.f1_score()
0.8275862068965516
0.8275862068965518
"""
return self.pr_hmean()
return self.fbeta_score(1.0)

@deprecated(
deprecated_in='0.4.0',
removed_in='0.6.0',
current_version=__version__,
details='Use the ConfusionTable.pr_hmean method instead.',
)
def f_measure(self):
r"""Return :math:`F`-measure.
Expand Down Expand Up @@ -1469,6 +1478,12 @@ def jaccard(self):
except ZeroDivisionError:
return float('nan')

@deprecated(
deprecated_in='0.4.0',
removed_in='0.6.0',
current_version=__version__,
details='Use the ConfusionTable.pr_gmean method instead.',
)
def g_measure(self):
r"""Return G-measure.
Expand Down

0 comments on commit f3182eb

Please sign in to comment.