Skip to content

API reference — Rule-Set Models

Quinlan C4.5 / C5.0 rule extraction, condition interval simplification, and pessimistic error rate pruning.

RuleModel

class RuleModel(kind: 'str' = 'c50', *, max_depth: 'int' = 6, min_rows: 'int' = 5, prune: 'bool' = True, cf: 'float' = 0.25) -> 'None'

Unified Rule-Set Extraction and Pruning Model.

Extracts, simplifies, and prunes transparent modular IF-THEN rules from decision trees using Quinlan's pessimistic error bound.

Parameters

kind : str, default="c50" Rule mining family: "c50", "c45", or "tree". max_depth : int, default=6 Maximum tree depth for the underlying decision tree. min_rows : int, default=5 Minimum leaf samples per rule. prune : bool, default=True Whether to greedily prune rule preconditions using pessimistic error bounds. cf : float, default=0.25 Quinlan's confidence factor CF for pessimistic pruning (default 0.25).

RuleModel.config

config(self) -> 'dict[str, Any]'

Return effective configuration dictionary.

RuleModel.fit

fit(self, x: 'Sequence[Sequence[Any]] | _CoreModelTree', y: 'Sequence[float] | None' = None) -> 'RuleModel'

Fit rule set on training data (X, y) or extract rules from an existing tree.

RuleModel.from_bytes

from_bytes(data: 'bytes') -> 'RuleModel'

RuleModel.from_json

from_json(data: 'str') -> 'RuleModel'

Restore fitted model from versioned JSON string.

RuleModel.load

load(path: 'str | Path') -> 'RuleModel'

RuleModel.predict

predict(self, x: 'Sequence[Sequence[Any]]') -> 'list[float]'

Predict target using the extracted rule set.

RuleModel.save

save(self, path: 'str | Path') -> 'None'

RuleModel.to_bytes

to_bytes(self) -> 'bytes'

RuleModel.to_json

to_json(self) -> 'str'

Return fitted model snapshot as JSON string.

RuleModel.default_confidence_

@default_confidence_

Confidence of the default fallback rule.

RuleModel.default_prediction_

@default_prediction_

Fallback prediction when no rule fires.

RuleModel.report

@report

Return the structured ModelReport.

RuleModel.rules_

@rules_

Extracted IF-THEN rules.

RuleResult

class RuleResult(rules: 'list[str]', predictions: 'list[float]', default_prediction: 'float', default_confidence: 'float', report: 'ModelReport') -> None

Fitted rule-set inference outputs.

RuleSet

class RuleSet()

An ordered set of IF-THEN rules with fallback default prediction.

RuleSet.predict

predict(self, /, x)

Rule

class Rule()

An individual IF-THEN rule extracted from a ModelTree.