Rule Evaluation Functions

This file contains the classes to perform rule classification evaluation.

class ex_fuzzy.eval_rules.evalRuleBase(mrule_base: MasterRuleBase, X: array, y: array, time_moments: array = None, precomputed_truth=None)[source]

Bases: object

Class to evaluate a set of rules given a evaluation dataset.

add_auxiliary_rule_weights() None[source]

Add dominance score field to each of the rules present in the master Rule Base for each consequent. They are labeled as aux_score, aux_support and aux_confidence. (Because they are not the main rule weights)

add_classification_metrics(X: array = None, y: array = None) None[source]

Adds the accuracy of each rule in the master rule base. It also adds the f1, precision and recall scores. If X and y are None uses the train set.

Parameters:
  • X – array of shape samples x features

  • y – array of shape samples

add_full_evaluation()[source]

Adds classification scores, both Dominance Scores and accuracy metrics, for each individual rule.

add_rule_weights() None[source]

Add dominance score field to each of the rules present in the master Rule Base.

association_degree() array[source]

Returns the association degree of each rule for each sample.

Returns:

vector of shape rules

aux_dominance_scores() array[source]

Returns the dominance score of each pattern for each rule.

Returns:

array of shape rules x 2

classification_eval() float[source]

Returns the matthews correlation coefficient for a classification task using the rules evaluated.

Returns:

mattews correlation coefficient. (float in [-1, 1])

compute_aux_pattern_confidence() array[source]

Computes the pattern confidence for each of the rules for the given X. Each pattern confidence is the normalized firing strength.

Returns:

array of shape rules x classes

compute_aux_pattern_support() array[source]

Computes the pattern support for each of the rules for each of the classes for the given X. Each pattern support firing strength is the result of the tnorm for all the antecedent memeberships, dvided by their number.

Returns:

array of shape rules x 2

compute_pattern_confidence() array[source]

Computes the pattern confidence for each of the rules for the given X. Each pattern confidence is the normalized firing strength.

Returns:

array of shape 1 x rules

compute_pattern_support() array[source]

Computes the pattern support for each of the rules for the given X. Each pattern support firing strength is the result of the tnorm for all the antecedent memeberships, dvided by their number.

Returns:

array of shape rules x 2

dominance_scores() array[source]

Returns the dominance score of each pattern for each rule.

Returns:

array of shape rules x 2

effective_rulesize_eval(tolerance=0.1) float[source]

Returns a score between 0 and 1, where 1 means that the rule base only contains almost no antecedents.

0 means that the rule base contains all rules with more than {tolerance} DS, there are many of them and they have all possible antecedents. The more rules and antecedent per rules the lower this score is.

Parameters:

tolerance – float in [0, 1]. The tolerance for the dominance score. Default 0.1

Returns:

float in [0, 1] with the score.

p_permutation_classifier_validation(n=100, r=10) float[source]

Performs a boostrap test to evaluate the performance of the rule base. Returns the p-valuefor the label permutation test and the feature coalition test.

Parameters:
  • n – int. Number of boostrap samples.

  • r – int. Number of repetitions to estimate the original error rate.

Returns:

p-value of the permutation test.

size_antecedents_eval(tolerance=0.1) float[source]

Returns a score between 0 and 1, where 1 means that the rule base only contains almost no antecedents.

0 means that the rule base contains all rules with more than {tolerance} DS, there are many of them and they have all possible antecedents. The more rules and antecedent per rules the lower this score is.

Parameters:

tolerance – float in [0, 1]. The tolerance for the dominance score. Default 0.1

Returns:

float in [0, 1] with the score.