pydvl.valuation.scorers.utils
¶
compose_score
¶
compose_score(
scorer: SupervisedScorer,
transformation: Callable[[float], float],
name: str,
) -> SupervisedScorer
Composes a scoring function with an arbitrary scalar transformation.
Useful to squash unbounded scores into ranges manageable by data valuation methods.
Example:
sigmoid = lambda x: 1/(1+np.exp(-x))
compose_score(Scorer("r2"), sigmoid, range=(0,1), name="squashed r2")
PARAMETER | DESCRIPTION |
---|---|
scorer |
The object to be composed.
TYPE:
|
transformation |
A scalar transformation |
range |
The range of the transformation. This will be used e.g. by [Utility][pydvl.valuation.utility.Utility] for the range of the composite scorer.
|
name |
A string representation for the composition, for
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
SupervisedScorer
|
The composite SupervisedScorer. |