Skip to content

solvi.core.deciders.rulelist

A readable rule list learned from examples (System.learn_rule): "if feature then answer", deterministic and replayable. solvi.rules up to 0.7.

Rules learned from examples instead of hand-written ones: an ordered "if feature then answer" list (a decision list) that can be read and audited. Features are built from computed facts: words of a string, leading digits of numbers in a string (codes), rounded numbers, category values. Fitting is greedy: at each step take the rule with the best precision on the not-yet-covered examples (with support ≥ min_support) while precision ≥ min_precision; last comes the default answer (the most frequent among the rest).

RuleList

RuleList(facts, min_support=3, min_precision=0.8, max_rules=40, *, max_literals=1, ngrams=1, negations=False, confirm=None)

calibrate

calibrate(rows, answers)

Per-firing-rule smoothed precision on independent, explicitly held-out rows.

fit

fit(rows, answers)

Learn the list from rows of facts and their answers; a second fit starts over (it replaces the list). When the list stops at max_rules while another rule would still pass min_precision, a warning says how many examples were left to the default answer (and truncated is that number; 0 otherwise).

words

words(text)

The upper-cased words and numbers of a text, in any script: runs of letters, digits, combining marks and apostrophes ("ул. Северная, 12" → УЛ, СЕВЕРНАЯ, 12; "Zürich" → ZÜRICH).