revscoring.scoring.statistics¶
Statistics represent the fitness of a revscoring.Model
. They can
be fit()
to scores and labels and
then output using format()
. Once
initialize, a Statistics
instance behaves like
a dict of statistics values.
Classification¶
Classification statistics can be generated for “Classifiers” – models that produce factors (aka levels) as an ouput. E.g. True and False or “A”, “B”, or “C”.
-
class
revscoring.scoring.statistics.
Classification
(labels, multilabel=False, prediction_key='prediction', decision_key=None, threshold_ndigits=None, population_rates=None, **kwargs)[source]¶ -
fit
(score_labels)[source]¶ Fit to scores and labels.
Parameters: - score_labels : [( dict, mixed )]
A collection of scores-label pairs generated using
revscoring.Model.score
. Note that fitting is usually done using data withheld during model training
-
format_json
(path_tree, **kwargs)[source]¶ Formats a json-able dictionary including rounding to at most ndigits.
-
-
class
revscoring.scoring.statistics.classification.
Counts
(labels, score_labels, prediction_key)[source]¶
-
class
revscoring.scoring.statistics.classification.
ScaledPredictionStatistics
(y_preds=None, y_trues=None, counts=None, population_rate=None)[source]¶ -
-
filter_rate
()[source]¶ The proportion of observations that are not matched.
filter-rate = 1 - match-rate
-
fpr
()[source]¶ False-positive rate. The proportion of proportion of non-target class items that are not matched.
fpr = false-positives / !target-class
-
match_rate
()[source]¶ The proportion of observations that are matched in prediction.
match-rate = positives / n
-
-
class
revscoring.scoring.statistics.classification.
ScaledThresholdStatistics
(y_decisions, y_trues, population_rate=None, threshold_ndigits=None)[source]¶
-
class
revscoring.scoring.statistics.classification.
ScaledClassificationMatrix
(y_preds=None, y_trues=None, counts=None, population_rate=None)[source]¶
-
class
revscoring.scoring.statistics.classification.
ThresholdOptimization
(maximize, target_stat, cond_stat, greater, cond_value)[source]¶ -
get_optimal
(threshold_statistics)[source]¶ Generates an optimized value by scanning a sequence of
ScaledThresholdStatistics
for a the best threshold that matches the conditional criteria. This function returns the entireScaledPredictionStatistics
mapping at the optimal threshold.
-
optimize_from
(threshold_statistics)[source]¶ Generates an optimized value by scanning a sequence of
ScaledThresholdStatistics
for a the best threshold that matches the conditional criteria. This function returns the value of the optimized target statistic (or None).
-
Abstract base class¶
-
class
revscoring.scoring.
Statistics
(*args, **kwargs)[source]¶ -
fit
(score_labels)[source]¶ Fit to scores and labels.
Parameters: - score_labels : [( dict, mixed )]
A collection of scores-label pairs generated using
revscoring.Model.score
. Note that fitting is usually done using data withheld during model training
-