When using Neuro-Fuzzy Designer, you can export your initial FIS structure to the MATLAB® workspace and then generate ANFIS training error values. Since exporting the training and validation error profiles from the Neuro-Fuzzy Designer app is not supported, use this method to generate such error plots.
The following example shows how to save the training error generated during ANFIS training to the MATLAB workspace.
Load your training data (fuzex1trnData
) and validation data
(fuzex1chkData
) to the MATLAB workspace.
load fuzex1trnData.dat load fuzex1chkData.dat
Open the Neuro-Fuzzy Designer app.
neuroFuzzyDesigner
Load the training data from the MATLAB workspace into Neuro-Fuzzy Designer.
In the Load data section, select Training.
Select worksp.
Click Load Data. In the Load from workspace
dialog box, enter the variable name fuzex1trnData
.
Click OK. Neuro-Fuzzy Designer displays the training data in the plot as a set of circles.
Load the checking data from the MATLAB workspace into Neuro-Fuzzy Designer. In the Load data section, select Checking.
Load the checking data in the same manner as the training data, specifying the
variable name fuzex1chkData
. Neuro-Fuzzy Designer
displays the checking data using plus signs superimposed on the training
data.
Generate an initial FIS.
In the Generate FIS section, select Grid partition.
Click Generate FIS.
In the Add Membership Functions dialog box:
In the Input section, in
Number of MFs, specify the number
of input membership functions. For this example use
4
for all input variables.
In MF Type, select
gbellmf
as the input membership
function type.
In the Output section, in
MF Type, select
linear
as the output membership
function type.
Click OK.
Export the initial FIS to the MATLAB workspace.
In Neuro-Fuzzy Designer, select File > Export > To Workspace.
This action opens a dialog box where you specify the MATLAB variable name.
In the Export To Workspace dialog box, in the Workspace
variable field, enter initfis
as the
variable name.
Click OK. The app exports the FIS object to the MATLAB workspace.
Train the FIS for 40
epochs. Instead of using a single call
to the anfis
function, call the function inside a loop
using 2
epochs for each call. This training method replicates
the training process used by the Neuro-Fuzzy Designer app.
At each training epoch, save the training and validation errors.
fis = initfis; opt = anfisOptions('EpochNumber',2,'ValidationData',fuzex1chkData); trainError = zeros(1,40); checkError = zeros(1,40); for ct = 1:40 opt.InitialFIS = fis; [fis,error,~,~,chkError] = anfis(fuzex1trnData,opt); trainError(ct) = error(1); checkError(ct) = chkError(1); end
Plot the training and validation errors over the training process. These error values are the root mean squared errors at each training epoch.
epochNum = 1:40; plot(epochNum,trainError,'b*',epochNum,checkError,'ro') xlabel('Epoch Number') ylabel('Error') legend('Training Error','Validation Error')
These error profiles are similar to the error profiles when the same initial FIS structure is trained in the Neuro-Fuzzy Designer app.