You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
def precision(pred_table):
"""
Precision given pred_table. Binary classification only. Assumes group 0
is the True.
Analagous to (absence of) Type I errors. Probability that a randomly
selected document is classified correctly. I.e., no false negatives.
"""
tp, fp, fn, tn = map(float, pred_table.flatten())
return tp / (tp + fp)
def recall(pred_table):
"""
Precision given pred_table. Binary classification only. Assumes group 0
is the True.
Analagous to (absence of) Type II errors. Out of all the ones that are
true, how many did you predict as true. I.e., no false positives.
"""
tp, fp, fn, tn = map(float, pred_table.flatten())
try:
return tp / (tp + fn)
except ZeroDivisionError:
return np.nan
def accuracy(pred_table):
"""
Precision given pred_table. Binary classification only. Assumes group 0
is the True.
"""
tp, fp, fn, tn = map(float, pred_table.flatten())
return (tp + tn) / (tp + tn + fp + fn)
def fscore_measure(pred_table, b=1):
"""
For b, 1 = equal importance. 2 = recall is twice important. .5 recall is
half as important, etc.
"""
r = recall(pred_table)
p = precision(pred_table)
try:
return (1 + b**2) * r*p/(b**2 * p + r)
except ZeroDivisionError:
return np.nan
If anyone would want to work on this, there is a start on a solution in #1650. Reading that would be a good place to start. That branch needs some tests and some small function API changes.
Activity
ENH: Add classification performance measures. Closes statsmodels#1577
ENH: Add classification performance measures. Closes statsmodels#1577
ysunmi0427 commentedon Jan 26, 2020
@jseabold I would like to work on this enhancement. Would you like to guide me to start working on this?
rluedde commentedon Jul 7, 2020
Correct me if I'm wrong but it looks like this has already been done? In file
statsmodels/tools/eval_measures.py@ysunmi0427 Do you agree?
anuragwatane commentedon Feb 23, 2021
We would like to work on this issue.
jseabold commentedon Apr 6, 2021
If anyone would want to work on this, there is a start on a solution in #1650. Reading that would be a good place to start. That branch needs some tests and some small function API changes.