Questions regarding the output of ANFIS, specifically Fis and chkFis.What is the difference between Fis and chkFis?

1 Ansicht (letzte 30 Tage)
Does Fis have a certain relationship with chkFis in this code? Is chkFis based on Fis and further adjusted for checking data to prevent overfitting? Additionally, I'd like to inquire about how training data and checking data are handled in each epoch. Are they processed simultaneously for training and checking, or is the checking conducted after training?If I want to continue testing with additional data, should I use Fis or chkFis?
clear
clc
numPts=51;
%数据点个数为51%输入数据%输出数据%整个数据集%训练数据集%检验数据集
x=linspace(-1,1,numPts);
y=0.5*sin(pi*x)+0.3*sin(3*pi*x)+0.1*sin(5*pi*x);data=[x' y'];
trnData=data(1:2:numPts,:);
chkData=data(2:2:numPts,:);
%绘制训练和检验数据的分布曲线
subplot(2,2,1);
plot(trnData(:,1),trnData(:,2),'o',chkData(:,1),chkData(:,2),'x');
legend('训练数据','检验数据');
title('训练和检验数据的分布曲线');
xlabel((1));
%采用genfis1()函数直接由训练数据生成Takagi-Sugeno型模糊推理系统
numMFs=5;
mfType='gbellmf';
%输入隶属度函数个数/类型
fisMat=genfis1(trnData,numMFs,mfType);
%绘制由函数genfsl()生成的模糊推理系统的初始输入变量的隶属度函数曲线
%初始模糊推理系统
subplot(2,2,2);
[x1,mf]=plotmf(fisMat,'input',1);
plot(x1,mf);
title('系统训练前的隶属度函数');
xlabel('(2)');%根据给定的训练数据利用函数anfs()训练自适应神经模糊系统
epochs=40;%训练次数为40
trnOpt=[epochs NaN NaN NaN NaN];
dispOpt=[ ];
[Fis,error,stepsize,chkFis,chkEr]=anfis(trnData,fisMat,trnOpt,dispOpt,chkData)
%绘制模糊推理系统由函数anfs()训练后的输入变量的隶属度函数曲线
subplot(2,2,3);
[x1,mf]=plotmf(Fis,'input',1);
plot(x1,mf);
title('系统训练后的隶属度函数');
xlabel('(3)');%计算训练后神经模糊系统的输出与训练数据的均方根误差trRMSE
trnOut1=evalfis(trnData(:,1),Fis);%训练后神经模糊系统的输出
trnOut2=evalfis(trnData(:,1),chkFis);
errs=trnOut1-trnOut2
trnRMSE1=norm(trnOut1-trnData(:,2))/sqrt(length(trnOut1 ))
trnRMSE2=norm(trnOut2-trnData(:,2))/sqrt(length(trnOut2))
%计算和绘制神经模糊推理系统的输出曲线
anfis_y1=evalfis(x,Fis);
anfis_y2=evalfis(x,chkFis);
qq=anfis_y1-anfis_y2
subplot(2,2,4);
plot(x,y,'-',x,anfis_y1,'x',x,anfis_y2,'o');
title('函数输出和ANFIS系统输出');
xlabel((4)');
legend('原函数的输出','ANFIS-1的输出','ANFIS-2的输出')

Antworten (1)

Shubham
Shubham am 10 Apr. 2024
Hi Guo,
In the provided code and context, Fis and chkFis are related to the process of training an Adaptive Neuro-Fuzzy Inference System (ANFIS) using MATLAB's Fuzzy Logic Toolbox. The relationship between Fis and chkFis and how training and checking data are handled during each epoch are crucial to understanding how ANFIS models are trained and validated to prevent overfitting. Let's break down your questions:
Relationship between Fis and chkFis
  • Fis represents the Fuzzy Inference System (FIS) model that is being trained using the training data (trnData). It starts as an initial model generated by genfis1 from the training data and is then refined through the training process using the anfis function.
  • chkFis is essentially a version of Fis that has been adjusted during training using the checking data (chkData). The purpose of chkFis is to monitor the training process for signs of overfitting. During training, ANFIS uses the checking data to validate the model at each epoch. If the model's performance on the checking data starts to degrade (indicating potential overfitting to the training data), ANFIS can stop adjusting the model or take other actions to prevent overfitting.
How Training Data and Checking Data are Handled
  • During each epoch of training, ANFIS adjusts the FIS model (Fis) based on the training data to minimize the error between the model's outputs and the actual outputs in the training data.
  • Simultaneously, ANFIS evaluates the adjusted FIS model on the checking data to monitor the model's performance on data it hasn't been trained on. This is done to ensure that the model generalizes well and isn't just memorizing the training data (overfitting).
  • The checking is conducted after each training epoch, and adjustments to prevent overfitting (like stopping the training early or adjusting the model parameters) are based on the model's performance on the checking data.
Which Model to Use for Further Testing (Fis or chkFis)
  • If your goal is to have a model that generalizes well to new, unseen data, you should use chkFis for further testing. This model has been adjusted to prevent overfitting based on its performance on the checking data.
  • Fis represents the model trained purely on the training data without adjustments for overfitting. It might perform better on the training data but could perform worse on new, unseen data compared to chkFis.
In summary, chkFis is typically the preferable model for testing and deploying in real-world scenarios because it is adjusted to mitigate overfitting, ensuring better generalization to new data.
  1 Kommentar
guo qing
guo qing am 10 Apr. 2024
Thank you for your detailed answer. I appreciate your clarification. Is it correct to say that during each training epoch, ANFIS adjusts parameters based on the training set, then validates its output error on the checking data? If the error on the checking data suddenly starts to increase, indicating the onset of overfitting, ANFIS begins to take measures to prevent overfitting, which is the role of chkFis. Your explanation has been very helpful.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Fuzzy Inference System Tuning finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by