Documentation

anfis

Training routine for Sugeno-type Fuzzy Inference System

Syntax

fis = anfis(trnData)
fis = anfis(trnData,initFIS)
fis = anfis(trnData,initFIS,trnOpt,dispOpt)
[fis,error] = anfis(___)
[fis,error,stepsize] = anfis(___)
[fis,error,stepsize,chkFis,chkErr] = anfis(trnData,initFIS,trnOpt,dispOpt,chkData)
[fis,error,stepsize,chkFis,chkErr] = anfis(trnData,initFIS,trnOpt,dispOpt,chkData,optMethod)

Description

anfis uses a hybrid learning algorithm to tune the parameters of a Sugeno-type fuzzy inference system (FIS). The algorithm uses a combination of the least-squares and back-propagation gradient descent methods to model a training data set. anfis also validates models using a checking data set to test for overfitting of the training data.

Input arguments for anfis are:

  • trnData — Training data, specified as a matrix. For an FIS with N inputs, trnData has N+1 columns, where the first N columns contain input data and the final column contains output data.

  • initFis — FIS structure used to provide an initial set of membership functions for training, specified as one of the following:

    • Positive integer — Specifies the number of membership functions for all inputs and generates an initial FIS using genfis1.

    • Vector of positive integers — Specifies the number of membership functions for each input individually and generates an initial FIS using genfis1.

    • An FIS structure, generated using genfis1 or genfis2, that satisfies these conditions:

      • First or zeroth order Sugeno-type system.

      • Single output, obtained using weighted average defuzzification. All output membership functions must be the same type and be 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 be equal to the number of rules.

      • Unity weight for each rule.

      • No custom membership functions or defuzzification methods.

    If initFis is not specified, anfis uses genfis1 to create a default initial FIS for training. The default FIS has two Gaussian membership functions for each input.

  • trnOpt — Training options, specified as a vector of scalars that represent the following settings:

    • trnOpt(1) — Training epoch number (default: 10)

    • trnOpt(2) — Training error goal (default: 0)

    • trnOpt(3) — Initial step size (default: 0.01)

    • trnOpt(4) — Step size decrease rate (default: 0.9)

    • trnOpt(5) — Step size increase rate (default: 1.1)

    When a training option is entered as NaN, the default options are used. If the length of trnOpt is less than five, the missing elements are set to their default values.

    The training process stops when it reaches the designated epoch number or achieves the training error goal.

  • dispOpt — Display options that specify information to display in the Command Window during training, specified as a vector of integers that represent these settings:

    • dispOpt(1) — ANFIS information, such as numbers of input and output membership functions

    • dispOpt(2) — Error values

    • dispOpt(3) — Step size at each parameter update

    • dispOpt(4) — Final results

    Each display option is specified as:

    • 1 (default) — Display the corresponding information.

    • 0 — Do not display the corresponding information.

    • NaN — The default option is used.

    If the length of dispOpt is less than four, the missing elements are set to their default values.

  • chkData — Validation data used to prevent overfitting of the training data, specified as a matrix. This matrix is in the same format as trnData. When you supply chkData as an input argument, specify chkFis and chkErr as output arguments to access the validation results.

  • optMethod — Optimization method used in membership function parameter training, specified as an integer with the following values:

    • 1 (default) — Hybrid method. This method is a combination of least-squares estimation and back-propagation.

    • 0 — Back-propogation method

    If any other value is specified, the default method is used.

    Note:   To use the default values, you can specify the optional arguments, initFIS, trnOpt, dispOpt, chkData, and optMethod as empty, [].

Output arguments for anfis are:

  • fis — FIS structure whose parameters are tuned using the training data, returned as a structure.

  • error — Root mean squared training data errors at each training epoch, returned as an array of scalars.

  • stepsize — Step sizes at each training epoch, returned as an array of scalars. If the error measure undergoes two consecutive combinations of an increase followed by a decrease, then anfis scales the step size by the decrease rate, trnOpt(4). If the error measure undergoes four consecutive decreases, then anfis scales the step size by the increase rate, trnOpt(5).

  • chkFis — FIS structure that corresponds to the epoch at which chkErr is minimum. The function returns chkFis only when you supply chkData as an input argument.

  • chkErr — Root mean squared checking data errors at each training epoch, returned as an array of scalars. The function returns chkErr only when you supply chkData as an input argument.

Examples

collapse all

Train ANFIS with Custom Number of Training Epochs

Create single-input-single-output training data.

x = (0:0.1:10)';
y = sin(2*x)./exp(x/5);
trnData = [x y];

Define an FIS structure with five bell-shaped input membership functions.

numMFs = 5;
mfType = 'gbellmf';
in_fis = genfis1(trnData,numMFs,mfType);

Train the FIS using 20 training epochs. Suppress the Command Window display.

epoch_n = 20;
dispOpt = zeros(1,4);
out_fis = anfis(trnData,in_fis,20,dispOpt);

Compare the ANFIS output with the training data.

plot(x,y,x,evalfis(x,out_fis));
legend('Training Data','ANFIS Output');

Related Examples

References

Jang, J.-S. R., "Fuzzy Modeling Using Generalized Neural Networks and Kalman Filter Algorithm," Proc. of the Ninth National Conf. on Artificial Intelligence (AAAI-91), pp. 762-767, July 1991.

Jang, J.-S. R., "ANFIS: Adaptive-Network-based Fuzzy Inference Systems," IEEE Transactions on Systems, Man, and Cybernetics, Vol. 23, No. 3, pp. 665-685, May 1993.

See Also

|

Introduced before R2006a

Was this topic helpful?