anfisand Neuro-Fuzzy Designer Functionality
This topic discusses the arguments and range components of the command-line function
anfis and the analogous functionality of the Neuro-Fuzzy
opt = anfisOptions; [fismat1,trnError,ss,fismat2,chkError] = anfis(trnData,opt);
trnDatais the training data. To use default training options, omit
opt. You can modify the default option set using dot notation. For more information on the available options and their default values, see the
anfisOptionsreference page. All output arguments other than
fismat1, the tuned fuzzy system, are optional.
When you open the Neuro-Fuzzy Designer, only the training data set
must exist before implementing
anfis. In addition, the step-size is
fixed when the adaptive neuro-fuzzy system is trained using this app.
The training data,
trnData, is a required argument to
anfis, and to the Neuro-Fuzzy Designer. Each row
trnData is a desired input/output pair of the target system
you want to model. Each row starts with an input vector and is followed by an output
value. Therefore, the number of rows of
trnData is equal to the
number of training data pairs. Since there is only one output, the number of columns
trnData is equal to the number of inputs plus one.
You can define the FIS object to tune using the
training option. You can create this object using:
The Fuzzy Logic Designer
The Membership Function Editor
The Rule Editor from the Neuro-Fuzzy Designer (which allows an FIS object to be loaded from a file or the MATLAB® workspace)
The command-line function,
which you only specify numbers and types of membership functions)
The FIS object contains both the model structure (which specifies such items as the number of rules in the FIS and the number of membership functions for each input) and the parameters (which specify the shapes of membership functions).
There are two methods that
learning employs for updating membership function parameters, which you can select
opt.OptimizationMethod training option:
Backpropagation for all parameters (a steepest descent method)
A 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
As a result, the training error decreases, at least locally, throughout the learning process. Therefore, the more the initial membership functions resemble the optimal ones, the easier it is for the model parameter training to converge. Human expertise about the target system to be modeled can aid in setting up these initial membership function parameters in the FIS object.
genfis function, when used with grid partitioning,
produces an FIS object based on a fixed number of membership functions. This object
can cause an excessive number of rules when the number of inputs is moderately
large; that is, more than four or five. Fuzzy Logic
Toolbox™ software offers a method that provides for some dimension reduction in
the fuzzy inference system: you can generate an FIS object using the clustering
algorithm discussed in Subtractive Clustering. To use the clustering
algorithm, you must select the Sub. Clustering option in the
Generate FIS portion of the Neuro-Fuzzy Designer
before the FIS is generated. This subtractive clustering method partitions the data
into clusters, and generates an FIS with the minimum number of rules required to
distinguish the fuzzy qualities associated with each clusters.
The Neuro-Fuzzy Designer allows you to choose your desired error tolerance and number of training epochs.
anfis command, you can specify training the training
termination condition and gradient descent step size. To specify the following
options, first create a default
anfisOptions option set,
opt. You can then modify the options using dot
opt.EpochNumber — Number of training epochs (default =
opt.ErrorGoal — Training error goal (default =
opt.InitialStepSize — Initial step-size (default =
opt.StepSizeDecreaseRate — Step-size decrease rate
opt.StepSizeIncreaseRate — Step-size increase rate
If you do not modify an option in
opt, the default value is
used. The training process stops if the designated epoch number is reached or the
error goal is achieved, whichever comes first.
Usually, the step-size profile is a curve that increases initially, reaches some
maximum, and then decreases for the remainder of the training. You achieve this
ideal step-size profile by adjusting the initial step-size and the increase and
decrease rates (
opt.StepSizeIncreaseRate). The default values are configured
to cover a wide range of learning tasks. For any specific application, you can
modify these step-size options to optimize the training. However, there are no
user-specified step-size options for training the adaptive neuro-fuzzy inference
system generated using the Neuro-Fuzzy Designer.
Display options apply only to the command-line function
anfis. You can specify what training progress information to
display in the MATLAB Command Window. As with the training options, you specify the display
options using the
anfisOptions option set,
. For each display option, if you specify a value of
(the default value), the corresponding data is displayed. Specifying a value of
0 suppresses the display:
opt.DisplayANFISInformation — Display ANFIS information
at the start of training
opt.DisplayErrorValues — Display the training error at
opt.DisplayStepSize — Display the step-size each time
opt.DisplayFinalResults — Display the final training
error and validation error
Both the Neuro-Fuzzy Designer and the command-line
anfis apply either a backpropagation form of the steepest
descent method for membership function parameter estimation, or a hybrid combination
of backpropagation and the least-squares methods. The choices for this argument are
backpropagation. To specify the
training method for the
anfis function, use the
opt.OptimizationMethod training option as either
fismat1 is the output FIS object corresponding to the minimum
training error. This FIS object is the one that you use to represent the fuzzy
system when there is no checking data used for model cross-validation.
fismat1 corresponds to the FIS object that the
Neuro-Fuzzy Designer saves when the checking data option is not used.
For more information on cross-validation using checking data, see Checking Data.
The training error is the difference between the training data output value, and
the output of the fuzzy inference system corresponding to the same training data
input value (the one associated with that training data output value). The training
trnError records the root mean squared error (RMSE) of the
training data set at each epoch.
fismat1 is the snapshot of the
FIS object when the training error measure is at its minimum.
The Neuro-Fuzzy Designer plots the training error versus epochs curve as the system is trained.
You cannot control the step-size options with the Neuro-Fuzzy Designer.
Using the command-line
anfis, the step-size array
ss records the step-size during the training. Plotting
ss gives the step-size profile, which serves as a reference
for adjusting the initial step-size (
opt.InitialStepSize) and the
corresponding decrease and increase rates. The step-size for the command-line
anfis is updated according to the following
If the error undergoes four consecutive reductions, increase the step-size
by multiplying it by a constant
opt.StepSizeIncreaseRate) greater than one.
If the error undergoes two consecutive combinations of one increase and
one reduction, decrease the step-size by multiplying it by a constant
opt.StepSizeDecreaseRate) less than one.
The default value for the initial step-size is
default values for
The checking data,
opt.ValidationData, is used for testing the
generalization capability of the fuzzy inference system at each epoch. The checking
data has the same format as the training data, and its elements are distinct from
those of the training data.
The checking data is important for learning tasks for which the input number is
large or the data itself is noisy. A fuzzy inference system should track a given
input/output data set well. Because 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 for
many training epochs. If overfitting does occur, the fuzzy inference system may not
respond well to other independent data sets, especially if they are noisy. A
validation or checking data set can be useful for these situations. This data set is
used to cross-validate the fuzzy inference model. This cross-validation requires
applying the checking data to the model and then seeing how well the model responds
to this data.
When the checking data option is used with
anfis, either via
the command line, or using the Neuro-Fuzzy Designer, the checking data is
applied to the model at each training epoch. When the command-line
anfis is invoked, the model parameters that correspond to
the minimum checking error are returned via the output argument
fismat2. When both training and checking data are loaded, the
FIS membership function parameters computed using the Neuro-Fuzzy
Designer are associated with the training epoch that has a minimum
The use of the minimum checking data error epoch to set the membership function parameters assumes the checking data:
Is similar enough to the training data that the checking data error decreases as the training begins.
Increases at some point in the training after the data overfitting occurs.
For information on using checking data, see Checking Data Does Not Validate Model.
The output of the command-line
fismat2, is the output FIS object with the minimum checking
error. This FIS object is the one that you should use for further calculation if
checking data is used for cross-validation.
fismat2 is only
returned if you specify validation data using
fismat2 corresponds to the FIS object that the Neuro-Fuzzy
Designer saves when the checking data option is used.
The checking error is the difference between the checking data output value, and
the output of the fuzzy inference system corresponding to the same checking data
input value, which is the one associated with that checking data output value. The
chkError records the RMSE for the checking data at
fismat2 is the snapshot of the FIS object when the
checking error is at its minimum.
chkError is only returned if
you specify validation data using
The Neuro-Fuzzy Designer plots the checking error versus epochs curve as the system is trained.