Rule Visualization#
Rule Visualization Module for Ex-Fuzzy Library
This module provides comprehensive visualization capabilities for fuzzy rule-based systems. It includes functions to visualize individual rules, rule bases, decision boundaries, and fuzzy variable partitions to aid in understanding and interpreting fuzzy models.
- Main Components:
Rule visualization: Graph-based representation of fuzzy rules and their relationships
Rule base analysis: Statistical and visual analysis of complete rule bases
Decision boundary plotting: Visual representation of classifier decision regions
Fuzzy partition visualization: Display of fuzzy variable linguistic terms
Interactive plots: Dynamic visualization tools for rule exploration
- Key Features:
Network-based rule visualization using NetworkX
Customizable color schemes and layout options
Export capabilities for publication-ready figures
Integration with matplotlib for high-quality plots
Support for both Type-1 and Type-2 fuzzy rule visualization
Rule importance and coverage analysis visualization
The module is designed to make fuzzy rule-based systems more interpretable and accessible, providing researchers and practitioners with powerful tools for understanding model behavior and communicating results effectively.
- ex_fuzzy.vis_rules.create_graph_connection(rules, possible_vl)[source]#
Returns a square matrix where each number indicates if two nodes are connected. Connectes by checking if both are in the same rule.
- Parameters:
rules – list with the rules.
possible_vl – number of linguistic variables.
- Returns:
square matrix where each number indicates if two nodes are connected.
- ex_fuzzy.vis_rules.choose_popular_rules(rule_matrix)[source]#
Returns the index of the rules that contain the most popular antecedent in the dataset.
- Parameters:
rule_matrix (array) – matrix with the rules.
- Returns:
numpy array with the rules that contain the most popular antecedent in the dataset.
- Return type:
array
- ex_fuzzy.vis_rules.connect_rulebase(rulebase)[source]#
Connects antecedents connected by checking if both are in the same rule.
- ex_fuzzy.vis_rules.connect_master_rulebase(mrule_base)[source]#
Connects antecedents connected by checking if both are in the same rule.
- Parameters:
mrule_base (MasterRuleBase) – Master rule base to connect.
- Returns:
List of list of pandas dataframes with the connections in adjacency matrix format.
- Return type:
- ex_fuzzy.vis_rules.visualize_rulebase(mrule_base, export_path=None)[source]#
Visualize a rule base using low, medium and high partitions with 1 rule in common -> 1 edge connections.
- Parameters:
mrule_base (MasterRuleBase) – Master rule base to visualize.
export_path (str) – Path to export the graph.
- ex_fuzzy.vis_rules.plot_fuzzy_variable(fuzzy_variable)[source]#
Plots a fuzzy variable using trapezoidal membership functions.
- Parameters:
fuzzy_variable (fuzzyVariable) – a fuzzy variable from the fuzzyVariable class in fuzzy_set module.
- Returns:
None
- Return type:
None
- ex_fuzzy.vis_rules.matrix_rule_base_form(rule_base)[source]#
Returns a matrix with the rule base in the form of a matrix to visualize.
- Parameters:
mrule_base – Rule base to transform.
- Returns:
Matrix with the rule base in the form of a matrix.
- Return type:
- ex_fuzzy.vis_rules.rules_to_latex(rule_base)[source]#
Prints the rule base in a latex format.
- Note:
if the rule base has three different linguistic labels, it will use custom commands for the partitions. You can define these commands (low, mid, hig, dc) to show colors, figures, etc. Be sure to recheck the DS, ACC values in this case, because 1.0 values of them are also converted to these commands.
- Parameters:
rule_base (MasterRuleBase) – the master rule base to print.
- Returns:
the String as a latex tabular.
- Return type: