ex_fuzzy.rules.RuleBaseGT2#
- class ex_fuzzy.rules.RuleBaseGT2(antecedents, rules, consequent=None, tnorm=<function prod>)[source]#
Bases:
RuleBase
Class optimized to work with multiple rules at the same time. Supports only one consequent. (Use one rulebase per consequent to study classification problems. Check MasterRuleBase class for more documentation)
This class supports gt2 fs. (ONLY FOR CLASSIFICATION PROBLEMS)
- __init__(antecedents, rules, consequent=None, tnorm=<function prod>)[source]#
Constructor of the RuleBaseGT2 class.
- Parameters:
antecedents (list[fuzzyVariable]) – list of fuzzy variables that are the antecedents of the rules.
rules (list[RuleSimple]) – list of rules.
consequent (fuzzyVariable) – fuzzy variable that is the consequent of the rules.
tnorm – t-norm used to compute the fuzzy output.
- inference(x)[source]#
Computes the output of the gt2 inference system.
Return an array in shape samples x alpha_cuts
- Parameters:
x (array) – array with the values of the inputs.
- Returns:
array with the memberships of the consequents for each sample.
- Return type:
array
- forward(x)[source]#
Computes the deffuzified output of the t2 inference system.
Return a vector of size (samples, )
- Parameters:
x (array) – array with the values of the inputs.
- Returns:
array with the deffuzified output for each sample.
- Return type:
array
- fuzzy_type()[source]#
Returns the correspoing type of the RuleBase using the enum type in the fuzzy_sets module.
- Returns:
the corresponding fuzzy set type of the RuleBase.
- Return type:
- compute_rule_antecedent_memberships(x, scaled=True, antecedents_memberships=None)[source]#
Computes the membership for the antecedents performing the alpha_cut reduction.
- Parameters:
x (array) – array with the values of the inputs.
scaled – if True, the memberships are scaled to sum 1 in each sample.
antecedents_memberships – precomputed antecedent memberships. Not supported for GT2.
- Returns:
array with the memberships of the antecedents for each sample.
- Return type:
array
- alpha_compute_rule_antecedent_memberships(x, scaled=True, antecedents_memberships=None)[source]#
Computes the membership for the antecedents for all the alpha cuts.
- Parameters:
x (array) – array with the values of the inputs.
scaled – if True, the memberships are scaled to sum 1 in each sample.
antecedents_memberships – precomputed antecedent memberships. Not supported for GT2.
- Returns:
array with the memberships of the antecedents for each sample.
- Return type:
array