revscoring.scoring¶
Scoring is what the revscoring library was designed to do. The basics of
scoring are revscoring.Model
that implement
score()
and revscoring.scoring.Statistics
that
are fit()
using the scores generated by a
revscoring.Model
. Prediction models are fragile, so models keep track
of their revscoring.scoring.Environment
and you can
revscoring.scoring.Environment.check()
them against the current
environment.
See revscoring.scoring.models
and revscoring.scoring.statistics
for more information.
-
class
revscoring.
Model
(features, version=None, environment=None, statistics=None, additional_info=None)[source]¶ -
-
info
= None¶ A
revscoring.scoring.ModelInfo
instance that implementslookup()
andformat()
– both of which act as an index into information about a model.
-
classmethod
load
(f, error_on_env_check=False)[source]¶ Reads serialized model information from a file.
-
score
(feature_values)[source]¶ Make a prediction or otherwise use the model to generate a score.
Parameters: - feature_values : collection(mixed)
an ordered collection of values that correspond to the Feature s provided to the constructor
Returns: A dict of statistics
-
test
(values_labels)[source]¶ Tests the model against a labeled data.
Parameters: - values_labels : iterable (( <feature_values>, <label> ))
an iterable of labeled data Where <values_labels> is an ordered collection of predictive values that correspond to the Feature s provided to the constructor
Returns: A dictionary of test results.
-
-
class
revscoring.scoring.
ModelInfo
(pairs=[], default_fields=None)[source]¶ -
format
(paths=None, formatting='str', **kwargs)[source]¶ Format a representation of the model information in a useful way.
Parameters: - paths : iterable ( str | [str] )
A set of paths to use when selecting which information should formatted. Everything beneath a provided path in the tree will be formatted. E.g. statistics.roc_auc and statistics will format redundantly because roc_auc is already within statistics. Alternatively statistics.roc_auc and statistics.pr_auc will format only those two specific bits of information.
- formatting : “json” or “str”
Which output formatting do you want? “str” returns something nice to show on the command-line. “json” returns something that will pass through
json.dump()
without error.
-