using fuzzy toolbox in matlab, try calculate error on validation set. first cross validation used split initial training data in training , test (validation) set. in validation phase obtain error different parameter setting in genfis3 function. vary fourth input in function 2 10 , calculate mean errors.
fismat3 = genfis3(x1,y1,'sugeno',2);
the entire code:
[m,~]=size(datatrain); cvo = cvpartition(m,'k',10); err = zeros(cvo.numtestsets,1); = 1:cvo.numtestsets tridx = cvo.training(i); teidx = cvo.test(i); x1=xtrain(tridx,:); x2=xtrain(teidx,:); y1=ytrain(tridx,:); y2=ytrain(teidx,:); fismat3 = genfis3(x1,y1,'sugeno',2); fismat3 = anfis([x1,y1],fismat3); out1=evalfis(x2,fismat3); ee=y2-out1; err(i)=mean(abs(ee)); end error32 = mean(err)
figured out:
[m,~]=size(datatrain); cvo = cvpartition(m,'k',10); err = zeros(cvo.numtestsets,9);%9 denotes amount of different parameter setting want validate out = zeros(cvo.numtestsets,1); ee = zeros(cvo.numtestsets,1); = 1:cvo.numtestsets %voor iedere test en training set tridx = cvo.training(i); %selecteer index training data teidx = cvo.test(i); %selecteer index test data x1=xtrain(tridx,:); %creer training input variabelen x2=xtrain(teidx,:); %creer test input variabelen y1=ytrain(tridx,:); % creer training output variable y2=ytrain(teidx,:); % creer test output variable j = 2:10 fismat3 = genfis3(x1,y1,'sugeno',j); %creer voor iedere test en training set een andere genfis 3 fismat3 = anfis([x1,y1],fismat3); %optimaliseer using anfis out1=evalfis(x2,fismat3); ee=y2-out1; err(i,j-1)=mean(abs(ee)); end end error = mean(err)
Comments
Post a Comment