compileml.compile

verify_monotone_constraints

def verify_monotone_constraints(model_int: dict, constraints) -> dict

from compileml.compile import verify_monotone_constraints

Check every quantized tree against the declared constraint signs.

Exact and cheap at any depth: a tree references at most depth features, so its cell grid is tiny. Per-tree monotonicity is sufficient for the whole model (monotone functions sum to a monotone function). Returns {"ok", "n_violations", "violations", "method"} with at most 20 example violations, each pinpointing the tree, the feature, the fixed context, and the offending leaf-value sequence.

Parameters#

NameTypeDefaultKind
model_intdictrequiredpositional
constraints—requiredpositional

Returns#

dict

Worked example: monotone_constraints →