jadinya nanti seperti ini:
Ini adalah kode Akurasinya:
data=get(handles.mytable2,'Userdata');
bar=size(data,1);
col=size(data,2);
anfis=readfis('myfis.fis');
tol=0.5;
hs=[];
jtrue=0;
for i=1:bar
dataUji=cell2mat(data(i,1:6)); %cell
actual=cell2mat(data(i,7));%cell
forecast=evalfis(dataUji,anfis);
hs(i,1)=actual;
hs(i,2)=forecast;
cekV=0;
sel=abs(actual-forecast);
if sel<=tol
cekV=1;
jtrue=jtrue+1;
end
hs(i,3)=cekV;
%%%%%%%%%%%%%%%%%%%%%%%%%%
xy4=actual-forecast;
xy5=abs(xy4);
xy6=xy5/actual;
xy7=xy6^2;
hs(i,4)=xy4;
hs(i,5)=xy5;
hs(i,6)=xy6;
hs(i,7)=xy7;
end
acc6=sum(hs(:,5));
acc7=sum(hs(:,6));
acc8=sum(hs(:,7));
mad=acc6/bar;
mape=acc7/bar;
msd=acc8/bar;
lap6=['MAD =' num2str(acc6) ' / ' num2str(bar) ' = ' num2str(mad)];
lap7=['MAPE=' num2str(acc7) ' / ' num2str(bar) ' = ' num2str(mape)];
lap8=['MSD =' num2str(acc8) ' / ' num2str(bar) ' = ' num2str(msd)];
presisi=(jtrue/bar)*100;
lap3=['Presisi =' num2str(jtrue) '/' num2str(bar) ' x 100%= ' num2str(presisi) ' %'];
dataGab=hs;
% $mad=$acc4/$jd;
% $mape=$acc5/$jd;
% $msd=$acc6/$jd;
nom=linspace(1,bar,bar);
axes(handles.axes2);
plot(nom,hs(:,1),'--rs','LineWidth',2,...
'MarkerEdgeColor','k',...
'MarkerFaceColor','g',...
'MarkerSize',10)
hold on;
plot(nom,hs(:,2),'--rs','LineWidth',2,...
'MarkerEdgeColor','k',...
'MarkerFaceColor','r',...
'MarkerSize',10)
hold off;
xlabel('Norm Data');
ylabel('Actual vc Forecast');
judul2={'Actual X','Forecast Y','Value','X-Y','||X-Y||','||X-Y||/X' '(X-Y)^2'};
nom=linspace(1,bar-1,bar-1);
set(handles.mytable3,'data',dataGab,'ColumnName',judul2,'RowName',nom);
set(handles.mytable3,'Userdata',dataGab);
lap2=['Banyak Data Training ' num2str(bar) ' Item'];
set(handles.tx2,'String',lap2);
set(handles.tx3,'String',lap3);
set(handles.tx4,'String',lap6);
set(handles.tx5,'String',lap7);
set(handles.tx6,'String',lap8);
myicon(:,:,1) = [0 1; 0 1];
myicon(:,:,2) = [.8 1; 0 .3];
myicon(:,:,3) = [.3 0; .9 .5];
h=msgbox('Sukses import','Success','custom',myicon);
mau=questdlg(['Generate Ulang ANFIS'],['KONFIRMASI'],'Ya','Tidak','Tidak');
if strcmp(mau,'Tidak')
return;
else
anfisedit;
end
function btnKeluar_Callback(hObject, eventdata, handles)
mau=questdlg(['Keluar dari Aplikasi ?'],['Keluar ' get(handles.figure1,'Name')''],'Ya','Tidak','Ya');
if strcmp(mau,'Tidak')
return;
end
% delete(handles.figure1);%close;
close();
function btnSet_Callback(hObject, eventdata, handles)
ButtonName = questdlg('Apakah Anda mau Generate Ulang Data Training', ...
'Pilih', ...
'Ya', 'Tidak', 'Tidak');
switch ButtonName,
case 'Ya',
data=get(handles.mytable1,'Userdata');
save data.mat data;
disp('Generate Ulang Data Traing');
h=msgbox('Sistem menggunakan Data Training yang baru...','REBUILD SUCCESS','help');
T = table(data);
%writetable(T, 'MyFile.txt'); support xls,csv dsb
%T = table(A, B, 'VariableNames', { 'A', 'B'} )
writetable(T,'data.txt','WriteVariableNames',0);
writetable(T,'data.dat','WriteVariableNames',0);
writetable(T,'data.csv','WriteVariableNames',0);
case 'Tidak',
global judul;
%judul={'Itensitas (Lux) ' 'Suhu (c)' 'Kelembapan Udara (%)' 'Kelembapan Tanah' 'Jumlah Daun' 'Lebar Tanaman' 'Panjang Batang'};
load data.mat;
bar=size(data,1);
nom=linspace(1,bar,bar);
set(handles.mytable1,'data',data,'ColumnName',judul,'RowName',nom);
disp('Tetap Menggunakan Data Training Yang Lama')
lap1=['Banyak Data Training ' num2str(bar) ' Item'];
set(handles.tx1,'String',lap1);
h=msgbox('Sistem kembali ke Data Training sebelumnya...','TURN BACK SUCCESS','help');
end % switch
% --- Executes on button press in btnGen.
function btnGen_Callback(hObject, eventdata, handles)
mau=questdlg(['Generate Ulang ANFIS'],['KONFIRMASI'],'Ya','Tidak','Tidak');
if strcmp(mau,'Tidak')
return;
else
anfisedit;
end
function btnPilih2_Callback(hObject, eventdata, handles)
global judul;
[namafile,direktori]=uigetfile({'*.xls;*.xlsx','file excel(*.xls,*.xlsx)';'*.*','semua file(*.*)'},'buka file excell');
alamatfile=fullfile(direktori,namafile);
[a,b,c]=xlsread(alamatfile);
set(handles.ed2,'String',alamatfile);
cek=cell2mat(b(1,1));
%Itensitas (Lux)
if strcmp(cek(1,1:9),"Itensitas")==0
myicon(:,:,1) = [0 1; 0 1];
myicon(:,:,2) = [.8 1; 0 .3];
myicon(:,:,3) = [.3 0; .9 .5];
h=msgbox('Salah Membuat Format Data Testing /Validasi','Cek File Testing #Header Itensitas','custom',myicon);
else
bar=size(c,1);
col=size(c,2);
%judul=c(1,1:col);
data=c(2:bar,1:col);
nom=linspace(1,bar-1,bar-1);
set(handles.mytable2,'data',data,'ColumnName',judul,'RowName',nom);
set(handles.mytable2,'Userdata',data);
lap2=['Banyak Data Training ' num2str(bar) ' Item'];
set(handles.tx2,'String',lap2);
myicon(:,:,1) = [0 1; 0 1];
myicon(:,:,2) = [.8 1; 0 .3];
myicon(:,:,3) = [.3 0; .9 .5];
h=msgbox('Sukses import','Success','custom',myicon);
end
function btnPilih_Callback(hObject, eventdata, handles)
[namafile,direktori]=uigetfile({'*.xls;*.xlsx','file excel(*.xls,*.xlsx)';'*.*','semua file(*.*)'},'buka file excell');
global judul;
alamatfile=fullfile(direktori,namafile);
[a,b,c]=xlsread(alamatfile);
set(handles.ed1,'String',alamatfile);
cek=cell2mat(b(1,1));
%Itensitas (Lux)
if strcmp(cek(1,1:9),"Itensitas")==0
myicon(:,:,1) = [0 1; 0 1];
myicon(:,:,2) = [.8 1; 0 .3];
myicon(:,:,3) = [.3 0; .9 .5];
h=msgbox('Salah Membuat Format Data Training','Cek File Training #Header Itensitas','custom',myicon);
else
bar=size(c,1);
col=size(c,2);
%judul=c(1,1:col);
%judul={'Itensitas (Lux) ' 'Suhu (c)' 'Kelembapan Udara (%)' 'Kelembapan Tanah' 'Jumlah Daun' 'Lebar Tanaman' 'Panjang Batang'};
data=c(2:bar,1:col);
nom=linspace(1,bar-1,bar-1);
set(handles.mytable1,'data',data,'ColumnName',judul,'RowName',nom);
set(handles.mytable1,'Userdata',data);
myicon(:,:,1) = [0 1; 0 1];
myicon(:,:,2) = [.8 1; 0 .3];
myicon(:,:,3) = [.3 0; .9 .5];
h=msgbox('Sukses import','Success','custom',myicon);
end
Tidak ada komentar:
Posting Komentar