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")What the rule reports
Section titled “What the rule reports”Calls to decompose() passing a lambda or sklearn.metrics function as scoring_function without a non-None functional= argument.
How to fix it
Section titled “How to fix it”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).
Diagnostic message
Section titled “Diagnostic message”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.