pydvl.valuation.scorers.supervised
¶
This module provides a SupervisedScorer class that wraps scoring functions for supervised problems with additional information.
Supervised scorers can be constructed in the same way as in scikit-learn: either from known strings or from a callable. Greater values must be better. If they are not, a negated version can be used, see scikit-learn's make_scorer().
SupervisedScorer holds the test data used to evaluate the model.
Named scorer
It is possible to use all named scorers from scikit-learn.
Model scorer
It is also possible to use the score()
function from the model if it defines one:
SupervisedScorer
¶
SupervisedScorer(
scoring: str
| SupervisedScorerCallable[SupervisedModelT, ArrayT]
| SupervisedModelT,
test_data: Dataset,
default: float,
range: tuple[float, float] = (-float("inf"), float("inf")),
name: str | None = None,
)
Bases: Generic[SupervisedModelT, ArrayT]
, Scorer
A scoring callable that takes a model, data, and labels and returns a scalar.
PARAMETER | DESCRIPTION |
---|---|
scoring
|
Either a string or callable that can be passed to get_scorer.
TYPE:
|
test_data
|
Dataset where the score will be evaluated.
TYPE:
|
default
|
score to be used when a model cannot be fit, e.g. when too little data is passed, or errors arise.
TYPE:
|
range
|
numerical range of the score function. Some Monte Carlo
methods can use this to estimate the number of samples required for a
certain quality of approximation. If not provided, it can be read from
the
TYPE:
|
name
|
The name of the scorer. If not provided, the name of the function passed will be used.
TYPE:
|
Tensor Support
SupervisedScorer supports both NumPy arrays and PyTorch tensors. Subclasses specialising in either type must specify the array type in the generic type.
New in version 0.5.0
Changed in version 0.10.0
This is now SupervisedScorer
and holds the test data used to evaluate the
model.
New in version 0.11.0
Added generic type support for arrays and tensor compatibility.