DTAnalyzer
- class pyruleanalyzer.DTAnalyzer(classifier: RuleClassifier)
Decision-Tree-specific rule analysis and comparison.
This class extracts the DT analysis pipeline out of
RuleClassifierand adds redundancy breakdown tracking so the output shows:intra_tree– boundary-redundant sibling pairs mergedlow_usage– rules removed because of low classification count
- classifier
The underlying
RuleClassifierinstance.
- redundancy_counts
Dict mapping redundancy type to count.
- compare_initial_final_results(file_path: str) None
Compares performance of initial vs final rules for a Decision Tree.
Evaluates both rule sets on the test data, displays metrics, logs divergent cases, and writes a detailed report.
- Parameters:
file_path – Path to the CSV test file.
- execute_rule_analysis(file_path: str, remove_below_n_classifications: int = -1) None
Evaluates DT rules on a dataset, detects redundancies, and refines.
This method: 1. Classifies every sample to gather per-rule usage stats. 2. Optionally removes low-usage rules (with sibling promotion). 3. Tracks redundancy counts by type. 4. Writes a report and saves the final model.
- Parameters:
file_path – Path to the CSV test file.
remove_below_n_classifications – Threshold for low-usage pruning (-1 disables).
- print_redundancy_summary() None
Prints the redundancy breakdown and rule reduction summary.
- track_intra_tree_from_duplicates(duplicated_rules_pairs: list) None
Updates the intra_tree counter from duplicate-pair detection.
Called by
RuleClassifier.execute_rule_analysis()after the duplicate-removal loop finishes for DT.- Parameters:
duplicated_rules_pairs – List of (rule1, rule2) tuples found by
find_duplicated_rules.