SONFIS
This module contains the implementation of the SONFIS (Self-Organizing
Neuro-Fuzzy Inference System) algorithm, which combines a parameter
learning algorithm with structural adaptation operators for rule growing,
splitting, and pruning. This algorithm is only applicable to
neuro_fuzzy_toolbox.models.anfis.rule_reduced_ANFIS models.
For more details on the SONFIS algorithm, refer to the original paper: SONFIS: Structure Identification and Modeling with a Self-Organizing Neuro-Fuzzy Inference System.
- class neuro_fuzzy_toolbox.training.sonfis.SONFIS(Ngrow, dGrow, Nsplit, eSplit, Nvanish, lVanish, max_iterations, ANFIStrainer, early_stopping=None, lse_for_new_consequents=False, lse_for_new_consequents_lambda=0.0, last_training_iteration=False)[source]
Bases:
base_model_trainerSelf-Organizing Neuro-Fuzzy Inference System (SONFIS) algorithm.
Combines a parameter learning algorithm with three structural adaptation operators (GrowNet, SplitSubNet, and VanishNet) to iteratively update both the parameters and the structure of a rule-reduced ANFIS model.
Note
This algorithm is only applicable to instances of
rule_reduced_ANFIS.- __call__(ANFISmodel, train_loader, val_loader=None, verbose=True)[source]
Runs the SONFIS algorithm.
At each iteration, the structural adaptation operators GrowNet, SplitSubNet, and VanishNet are applied, followed by a parameter update of the modified subnets. The algorithm stops when no structural updates occur or the maximum number of iterations is reached. If early stopping is enabled and a validation DataLoader is provided, the algorithm may also stop early based on the validation loss.
- Parameters:
ANFISmodel (rule_reduced_ANFIS) – Rule-reduced ANFIS model to train.
train_loader (DataLoader) – DataLoader containing the training data.
val_loader (DataLoader) – DataLoader containing the validation data. Defaults to
None.verbose (bool) – If
True, prints progress and structural update messages at each iteration. Defaults toTrue.
- __init__(Ngrow, dGrow, Nsplit, eSplit, Nvanish, lVanish, max_iterations, ANFIStrainer, early_stopping=None, lse_for_new_consequents=False, lse_for_new_consequents_lambda=0.0, last_training_iteration=False)[source]
Initializes a new SONFIS instance.
- Parameters:
Ngrow (int) – Minimum number of poorly modeled samples required to grow a new subnet.
dGrow (float) – Threshold for identifying poorly modeled samples. A sample is considered poorly modeled if its maximum firing level across all subnets is less than or equal to this value raised to the power of the input dimensionality.
Nsplit (int) – Minimum number of samples associated with a subnet for it to be considered for splitting.
eSplit (float) – Minimum loss value of the samples associated with a subnet for it to be considered for splitting.
Nvanish (int) – Maximum number of samples associated with a subnet below which its age counter is incremented.
lVanish (int) – Maximum age of a subnet before it is removed.
max_iterations (int) – Maximum number of structural adaptation iterations.
ANFIStrainer (base_model_trainer) – Instantiated ANFIS training algorithm that defines how the model parameters are updated at each iteration.
early_stopping (EarlyStopping) – Early stopping mechanism to use during the SONFIS iterations. Defaults to
None.lse_for_new_consequents (bool) – If
True, the consequent parameters of rules generated by GrowNet or SplitSubNet are initialized using least-squares estimation instead of random initialization. Defaults toFalse.lse_for_new_consequents_lambda (float) – Lambda value for Ridge regularization in the least-squares initialization of new consequent parameters. If
0., no regularization is applied. Defaults to0..last_training_iteration (bool) – If
True, performs a final parameter update over all subnets after the SONFIS algorithm finishes. Defaults toFalse.