Skip to content

model_diagnostics/decompose-custom-missing-functional

Pack Severity Fix Versions
model-diagnostics error none, edit by hand All versions

model_diagnostics.scoring.decompose() inspects scoring_function.functional when functional=None. Built-in score objects (SquaredError(), PinballLoss(), LogLoss(), PoissonDeviance(), GammaDeviance()) define .functional, whereas a lambda or sklearn.metrics function does not and raises ValueError: You set functional=None, but scoring_function has no attribute functional.

decompose(y_val, y_pred, scoring_function=lambda y, p, w: (y - p) ** 2)
decompose(y_val, y_pred, scoring_function=lambda y, p, w: (y - p) ** 2, functional="mean")

Calls to decompose() passing a lambda or sklearn.metrics function as scoring_function without a non-None functional= argument.

Pass an explicit functional= ("mean", "median", "quantile", or "expectile", plus level= for quantiles and expectiles), or use a built-in model_diagnostics.scoring class such as SquaredError() or PinballLoss(level=0.9).

decompose() raises ValueError when scoring_function is a custom callable without a .functional attribute and functional= is omitted or None. Pass functional="mean", "median", "quantile", or "expectile" (or use a model_diagnostics.scoring class).

See all rules in the model-diagnostics pack.