Skip to content

fix(trxf): weight only rules that fire for the assignment - #214

Open
Hanabi9248 wants to merge 1 commit into
Trusted-AI:masterfrom
Hanabi9248:codex/trxf-fired-rule-weighting-oct25
Open

Hanabi9248 wants to merge 1 commit into
Trusted-AI:masterfrom
Hanabi9248:codex/trxf-fired-rule-weighting-oct25

Conversation

@Hanabi9248

Copy link
Copy Markdown

WEIGHTED_SUM and WEIGHTED_MAX currently aggregate every rule without evaluating the input assignment. A trained model can therefore choose an unfired high-weight label, return the same label for mutually exclusive inputs, or fail on an empty rule collection. The constructor describes conflict resolution among fired rules and a default label when nothing matches; the PMML reader maps these modes to the same firing-rule strategies (https://dmg.org/pmml/v4-4/RuleSet.html).

Filter nonfiring conjunctions in both weighted branches and return the configured default for empty/no-hit models. Preserve FIRST_HIT, the existing nonempty first-rule weight initialization assertion, label aggregation order and existing tie behavior. This does not redesign PMML tie handling, change metrics or the Feature parser, or initialize weights automatically.

Validation against master 0ce916f on Python 3.11.16:

  • New regression: 12 methods. Baseline has 16 assertion failures and four empty-rule IndexErrors; candidate passes all 12. These include subcases for both weighted modes.
  • Separate unchanged upstream classifier suite: all four methods pass with the candidate, including metric updates and both weighted modes.
  • The regression executes complete real Feature/Predicate/Conjunction/DNF/utils/metrics/classifier modules with actual NumPy 1.26.4, pandas 2.3.3 and sklearn 1.5.2. Core cases call update_rules_with_metrics on DataFrames/Series and check the computed weights before prediction; no inference, metrics, dataframe or weight replacement is mocked. Namespace-only package containers isolate unrelated optional top-level imports.
  • Controls cover distinct sum/max aggregation, false/empty defaults, zero-weight firing rules, empty conjunctions, FIRST_HIT, weight initialization, existing ties, missing-feature propagation and unknown modes.
  • Exact source blobs and the final two-file patch were checked. Added-lines whitespace checks pass. Native runs used CPU1/768MiB/16 processes/private temporary files/single-threaded BLAS; no dependencies were installed.

Run: python tests/rule_induction/trxf/classifier/test_fired_rule_weighting.py -v

Python 3.10, other Python versions, full installed-package imports, PMML serialization/runtime integration and the full repository suite were not run. This is separate from #211 metrics and #213 arithmetic operand grouping. AI assistance was used in preparing/reviewing the change; reported results are actual local runs.

Return the configured default when no weighted rule fires, preserving
existing weight initialization guards and label aggregation order.

Signed-off-by: Hanabi <317387557+Hanabi9248@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant