## Neuro-Adaptive Learning and ANFIS

Suppose that you want to apply fuzzy inference to a system for which you already have a collection of input/output data that you would like to use for modeling, model-following, or some similar scenario. Also, assume that you do not necessarily have a predetermined model structure based on the characteristics of variables in your system. In some modeling situations, discerning membership functions parameters by looking at data can be difficult or impossible. In these cases, rather than choosing the parameters associated with a given membership function arbitrarily, you can tailor the membership function parameters to the input/output data. Using Fuzzy Logic Toolbox™ software, you can tune Sugeno fuzzy inference systems using neuro-adaptive learning techniques similar to those used for training neural networks.

Using Fuzzy Logic Toolbox software you can train an adaptive neuro-fuzzy inference system (ANFIS):

At the command line, using the

`anfis`

function.At the command line, using the

`tunefis`

function.In the

**Fuzzy Logic Designer**app. For an example, see Tune Fuzzy Inference System Using Fuzzy Logic Designer.

### FIS Structure

Using ANFIS training methods, you can train Sugeno systems with the following properties:

Single output

Weighted average defuzzification

First or zeroth order system; that is, all output membership functions must be the same type, either

`'linear'`

or`'constant'`

.No rule sharing. Different rules cannot use the same output membership function; that is, the number of output membership functions must equal the number of rules.

Unity weight for each rule.

No custom membership functions or defuzzification methods.

To create such a fuzzy system in the MATLAB^{®} workspace, you can:

Use the

`genfis`

function. When using this method, you can create your system using either grid partitioning or subtractive clustering. Grid partitioning can produce a large number of rules when the number of inputs reaches four or five. To reduce the number of rules, consider using the subtractive clustering method.Use the

`sugfis`

function.Load a system from a file using the

`readfis`

function.Using

**Fuzzy Logic Designer**. For an example, see Build Fuzzy Systems Using Fuzzy Logic Designer.

### Training Data

To train a fuzzy system using neuro-adaptive methods, you must collect input/output training data using experiments or simulations of the system you want to model and define it in the MATLAB workspace. In general, ANFIS training works well if the training data is fully representative of the features of the data that the trained FIS is intended to model.

When you define training data for the `anfis`

function, specify
it as a single array. Each row contains a data point, with the final column
containing the output value and the remaining columns containing input
values.

When you define training data for tuning with `tunefis`

or **Fuzzy Logic
Designer** app, create and import separate input and output arrays. Each
array contains the corresponding input or output data for a data point.

### Training Options

To configure the training process, you can adjust the ANFIS tuning settings. For more information on configuring options for the:

**Fuzzy Logic Designer**app, see Configure Tuning Options in Fuzzy Logic Designer.`tunefis`

function, see`tunefisOptions`

.`anfis`

function, see`anfisOptions`

.

Using all of the tuning methods, you can configure the following tuning options.

Option | Description |
---|---|

Optimization Method | Optimization method used in membership function parameter training. |

Number of training epochs | Maximum number of training epochs, specified as a positive integer. |

Training error goal | Training error goal, specified as a scalar. The training process stops when the training error is less than or equal to the training error goal. |

Initial step size | Initial training step size, specified as a positive scalar. |

Step-size decrease rate | Step-size decrease rate, specified as a positive scalar less than
`1` . |

Step-size increase rate | Step-size increase rate, specified as a scalar greater than
`1` . |

#### Optimization Method

To train a fuzzy system using ANFIS tuning, the Fuzzy Logic Toolbox software uses one of the following methods:

A steepest-decent backpropagation approach for all parameters.

Hybrid method consisting of backpropagation for the parameters associated with the input membership functions, and least squares estimation for the parameters associated with the output membership functions.

#### Step Size

When training an ANFIS system, you can adjust the training step size options. During training, the software updates the step size according to the following rules:

If the error undergoes four consecutive reductions, increase the step size by multiplying it by the step-size increase rate.

If the error undergoes two consecutive combinations of one increase and one reduction, decrease the step size by multiplying it by the step-size decrease rate.

Ideally, the step size increases at the start of training, reaches a maximum, and then decreases for the remainder of the training. To achieve this step size profile, adjust the initial step size, step-size increase rate, and step-size decrease rate.

### Training Validation

Validation data lets you check the generalization capability of your trained fuzzy inference system. The validation data should fully represent the features of the data the FIS is intended to model, while also being sufficiently different from the training data to test training generalization. The software uses this data set to cross-validate the fuzzy inference model by applying the validation data to the model and seeing how well the model responds to this data.

Model validation is useful in the following situations:

Noisy data — In some cases, data is collected using noisy measurements, and the training data is unable to represent all the features of the data the FIS is intended to model.

Overfitting — Since the model structure used for ANFIS is fixed with a large number of parameters, there is a tendency for the model to overfit the data on which it is trained, especially when using a large number of training epochs. If overfitting does occur, the trained FIS may not generalize well to other independent data sets.

The idea behind using a validation data set for model validation is that, after a certain point in the training process, the model begins overfitting the training data set. In principle, the model error for the validation data set decreases up to the point that overfitting begins. After this point, the model error for the validation data increases. Overfitting is accounted for by testing the trained FIS against the validation data, and choosing the membership function parameters to be those associated with the minimum validation error if these errors indicate model overfitting.

Usually, the training and validation data sets are collected based on observations of the target system and are then stored in separate files.

The array and file formats for the validation data are the same as those for the training data.

## References

[1] Jang, J.-S. R. "Fuzzy
Modeling Using Generalized Neural Networks and Kalman Filter Algorithm."
*Proceedings of the Ninth National Conference on Artificial
Intelligence (AAAI-91)*, (July 1991): 762–767.

[2] Jang, J.-S. R. "ANFIS:
Adaptive-Network-based Fuzzy Inference Systems." *IEEE Transactions on
Systems, Man, and Cybernetics* 23, no. 3 (May 1993):
665–685.

[3] Jang, J.-S.R., and N.
Gulley. "Gain Scheduling Based Fuzzy Controller Design." In *NAFIPS/IFIS/NASA ’94. Proceedings of the First International Joint Conference
of The North American Fuzzy Information Processing Society Biannual Conference.
The Industrial Fuzzy Control and Intelligent Systems Conference, and the NASA
Joint Technology Wo*, 101–5. San Antonio, TX, USA: IEEE, 1994. https://doi.org/10.1109/IJCF.1994.375142.

[4] Jang, J.-S.R. and
Chuen-Tsai Sun. ‘Neuro-Fuzzy Modeling and Control’. *Proceedings of the IEEE* 83, no. 3 (March 1995):
378–406.

[5] Jang, Jyh-Shing Roger,
Chuen-Tsai Sun, and Eiji Mizutani. *Neuro-Fuzzy and Soft
Computing: A Computational Approach to Learning and Machine
Intelligence*. MATLAB Curriculum Series. Upper Saddle River, NJ:
Prentice Hall, 1997.

[6] Wang, Li-Xin. *Adaptive Fuzzy Systems and Control: Design and Stability
Analysis*. Englewood Cliffs, NJ: PTR Prentice Hall,
1994.

[7] Widrow, B. and D. Stearns,
*Adaptive Signal Processing*, Prentice Hall,
1985.