compileml.compile

extract_trees

def extract_trees(model) -> compileml.compile.extract.ExtractedModel

from compileml.compile import extract_trees

Extract a fitted model into float tree arrays; dispatches on family.

An :class:`ExtractedModel` passes through unchanged. That is what lets a caller extract a boosted model once and build artifacts from prefixes of its trees — the first k trees of a boosted fit *are* the k-tree model — without refitting.

Parameters#

NameTypeDefaultKind
model—requiredpositional

Returns#

compileml.compile.extract.ExtractedModel

Raises#

  • TypeError
  • ValueError

Read from the function body and the private helpers it calls, not inferred. A function that raises nothing has no section here.

Example#

python
from compileml.compile import extract_trees
 
extracted = extract_trees(whitebox)
print(extracted.n_features, len(extracted.trees))