Save Training Error Data to MATLAB Workspace

When using Neuro-Fuzzy Designer, you can export your initial FIS structure to the MATLAB® workspace and then save the ANFIS training error values in the workspace.

The following example shows how to save the training error generated during ANFIS training to the MATLAB workspace:

  1. Load the training and checking data in the MATLAB workspace by typing the following commands at the MATLAB prompt:

    load fuzex1trnData.dat
    load fuzex1chkData.dat
    

  2. Open the Neuro-Fuzzy Designer by typing the following command:

    neuroFuzzyDesigner

  3. Load the training data from the MATLAB workspace into the Neuro-Fuzzy Designer:

    1. In the Load data panel of the Neuro-Fuzzy Designer, verify that Training is selected in the Type column.

    2. Select worksp in the From column.

    3. Click Load Data to open the Load from workspace dialog box.

    4. Type fuzex1trnData, and click OK.

      The Neuro-Fuzzy Designer displays the training data in the plot as a set of circles (○).

  4. Load the checking data from the MATLAB workspace into the Neuro-Fuzzy Designer:

    1. In the Load data panel of the Neuro-Fuzzy Designer, select Checking in the Type column.

    2. Click Load Data to open the Load from workspace dialog box.

    3. Type fuzex1chkData as the variable name, and click OK.

      The Neuro-Fuzzy Designer displays the checking data as plus signs (+) superimposed on the training data.

  5. Generate an initial FIS:

    1. In the Generate FIS panel, verify that Grid partition option is selected.

    2. Click Generate FIS.

      This action opens a dialog box where you specify the structure of the FIS.

    3. In the dialog box, specify the following:

      • Enter 4 in the Number of MFs field.

      • Select gbellmf as the Membership Type for the input.

      • Select linear as the Membership Type for the output.

    4. Click OK to generate the FIS and close the dialog box.

  6. Export the initial FIS to the MATLAB workspace:

    1. In the Neuro-Fuzzy Designer, select File > Export > To Workspace.

      This action opens a dialog box where you specify the MATLAB variable name.

    2. In the dialog box, in the Workspace variable text box, enter initfis.

    3. Click OK to close the dialog box.

      A variable named initfis now appears in the MATLAB workspace.

  7. Train the FIS for 40 epochs by typing the following command at the MATLAB prompt:

    figure
    hold on
    fismat = initfis;
    opt = anfisOptions('EpochNumber',2,'ValidationData',fuzex1chkData);
    for ct = 1:40
        opt.InitialFIS = fismat;
        [fismat,error] = anfis(fuzex1trnData,opt);
        plot(ct,error(1),'b*');
    end

    To improve accuracy when you train the FIS, the code uses the results of the current iteration returned by the anfis command as the initial conditions for the next iteration. The output argument error contains the root mean squared errors representing the training data error. For more information, see the anfis reference page.

    The plot of the training error versus the number of epochs appears in the next figure.

See Also

Related Topics