Rule Visualization

This is a the source file that contains the functions necessary to visualize the set of rules.

Returns the index of the rules that contain the most popular antecedent in the dataset.

Parameters:

rule_matrix – matrix with the rules.

Returns:

numpy array with the rules that contain the most popular antecedent in the dataset.

ex_fuzzy.vis_rules.connect_master_rulebase(mrule_base: MasterRuleBase) list[list[array]][source]

Connects antecedents connected by checking if both are in the same rule.

Parameters:

mrule_base – Master rule base to connect.

Returns:

List of list of pandas dataframes with the connections in adjacency matrix format.

ex_fuzzy.vis_rules.connect_rulebase(rulebase: RuleBase) list[array][source]

Connects antecedents connected by checking if both are in the same rule.

Parameters:

rulebase – Rule base to connect.

Returns:

List of pandas dataframes with the connections in adjacency matrix format.

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.filter_useless_columns(df: DataFrame) DataFrame[source]

Filter columns with only one value.

Parameters:

df – Dataframe to filter.

Returns:

Filtered dataframe.

ex_fuzzy.vis_rules.matrix_rule_base_form(rule_base: Rule) DataFrame[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.

ex_fuzzy.vis_rules.plot_fuzzy_variable(fuzzy_variable: fuzzyVariable) None[source]

Plots a fuzzy variable using trapezoidal membership functions.

Parameters:

fuzzy_variable – a fuzzy variable from the fuzzyVariable class in fuzzy_set module.

Returns:

None

ex_fuzzy.vis_rules.rules_to_latex(rule_base: MasterRuleBase) str[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 – the master rule base to print.

Returns:

the String as a latex tabular.

ex_fuzzy.vis_rules.visualize_rulebase(mrule_base: MasterRuleBase, export_path: str = None) None[source]

Visualize a rule base using low, medium and high partitions with 1 rule in common -> 1 edge connections.

Parameters:
  • mrule_base – Master rule base to visualize.

  • export_path – Path to export the graph.