'OUTPUT' 'PREDIKSI1' 'T/F' 'PREDIKSI2' 'T/F'
1 7 0 1 1
1 7 0 1 1
1 7 0 1 1
1 7 0 1 1
1 7 0 1 1
2 2 1 2 1
2 2 1 2 1
2 2 1 2 1
2 2 1 2 1
2 2 1 2 1
3 3 1 3 1
3 3 1 3 1
3 3 1 3 1
3 3 1 3 1
3 3 1 3 1
4 4 1 4 1
4 4 1 4 1
4 4 1 4 1
4 4 1 4 1
4 4 1 4 1
5 5 1 5 1
5 5 1 5 1
5 5 1 5 1
5 5 1 5 1
5 5 1 5 1
6 6 1 6 1
6 6 1 6 1
6 6 1 6 1
6 6 1 6 1
6 6 1 6 1
7 7 1 7 1
7 7 1 7 1
7 7 1 7 1
7 7 1 7 1
7 7 1 7 1
output adalah terget yang harus di capai...
misal 1: kucing Angora, 2 Kucing Bengal, 3 Brits, 4 Exotic, 5 Mainecoon, 6 Persia dan 7 Sphynx
Menggunakan Metode SVM model Grayscale (rgb2gray): hasilnya kurang baik
Menggunakan Metode SVM model R+G/2(Red dan green saja): hasilnya lebih baik bahkan 100% benar
'T/F' =>1=true, 2 false atau tidak sesuai target
Saat menggunakan Kmeans hasilya kurang baik karena disini menggunakan rumus labeling....
pil1=get(handles.pil1,'Userdata')
pil2=get(handles.pil2,'Userdata')
pil3=get(handles.pil3,'Userdata')
pil4=get(handles.pil4,'Userdata')
data=get(handles.mytable3,'Userdata');
data0=get(handles.mytable4,'Userdata');
if size(data,1)<1
msgbox('Silakan pilih data latih dahhulu...','Lengkapi Data','help');
return;
end
ROW=data(:,1)
co=size(data0,2);
mydata=data0(:,2:co);
mydatabaru=[pil1,pil2,pil3,pil4]
F=[mydata;mydatabaru];
K=8;
opts = statset('Display','final');
[prediction, CENTS] = kmeans(F, K, 'Distance','city','Replicates',40, 'Options',opts);
header=["X1","X2","X3","X4"];
c=size(CENTS,1);
T=size(prediction,1);
hsl=prediction(T);
row=linspace(1,c,c);
set(handles.mytable5,'data',CENTS,'ColumnName',header,'RowName',row);
set(handles.mytable5,'Userdata',CENTS);
OUT=cell2mat(ROW(hsl));
set(handles.edknn,'String',num2str(OUT));
+++++++++++++++++++
Perhitungan Normalsiasi SVM menggunalan rumus ini:
load DLATIH.mat;
load DLATIH2.mat;
load ROW.mat;
load ROW2.mat;
load KAT.mat;
kolom={'Contrast' 'Correlation' 'Energy' 'Homogeneity'};
set(handles.mytable,'data',DLATIH,'ColumnName',kolom,'RowName',ROW);
set(handles.mytable,'Userdata',DLATIH);
%%%%%%%%%%%%%%%
set(handles.mytable2,'data',DLATIH2,'ColumnName',kolom,'RowName',ROW);
set(handles.mytable2,'Userdata',DLATIH2);
%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%
X =DLATIH;
Y = KAT;
prediction=multisvm(DLATIH,KAT,DLATIH);
prediction2=prediction';
ba=size(prediction2,2);
benar=0;
rekap1=[];
for i=1:ba
if(KAT(1,i)==prediction2(1,i))
benar=benar+1;
rekap1(1,i)=1;
else
rekap1(1,i)=0;
end
end
salah=ba-benar;
akurasi1=benar/ba;
prediction=multisvm(DLATIH2,KAT,DLATIH2);
prediction22=prediction';
ba=size(prediction22,2);
benar=0;
rekap2=[];
for i=1:ba
if(KAT(1,i)==prediction22(1,i))
benar=benar+1;
rekap2(1,i)=1;
else
rekap2(1,i)=0;
end
end
salah=ba-benar;
akurasi2=benar/ba;
GAB=[KAT' prediction2' rekap1' prediction22' rekap2']
row=linspace(1,ba,ba);
header={'OUTPUT','PREDIKSI1','T/F','PREDIKSI2','T/F'}
set(handles.mytable0,'data',GAB,'ColumnName',header,'RowName',row);
set(handles.mytable0,'Userdata',GAB);
Sedang raget yang hendak dicapai lebihd ari 2 item maka menggunakan rumsu Multisvm sbb:
function [itrfin] = multisvm( T,C,test )
itrind=size(test,1);
itrfin=[];
Cb=C;
Tb=T;
for tempind=1:itrind
tst=test(tempind,:);
C=Cb;
T=Tb;
u=unique(C);
N=length(u);
c4=[];
c3=[];
j=1;
k=1;
if(N>2)
itr=1;
classes=0;
cond=max(C)-min(C);
while((classes~=1)&&(itr<=length(u))&& size(C,2)>1 && cond>0)
c1=(C==u(itr));
newClass=c1;
svmStruct = svmtrain(T,newClass,'kernel_function','polynomial');
classes = svmclassify(svmStruct,tst);
for i=1:size(newClass,2)
if newClass(1,i)==0;
c3(k,:)=T(i,:);
k=k+1;
end
end
T=c3;
c3=[];
k=1;
for i=1:size(newClass,2)
if newClass(1,i)==0;
c4(1,j)=C(1,i);
j=j+1;
end
end
C=c4;
c4=[];
j=1;
cond=max(C)-min(C);
if classes~=1
itr=itr+1;
end
end
end
valt=Cb==u(itr);
val=Cb(valt==1);
val=unique(val);
itrfin(tempind,:)=val;
end
end
'Anggora'
'Anggora'
'Anggora'
'Anggora'
'Anggora'
'Bengal'
'Bengal'
'Bengal'
'Bengal'
'Bengal'
'Britsh'
'Britsh'
'Britsh'
'Britsh'
'Britsh'
'Exotic'
'Exotic'
'Exotic'
'Exotic'
'Exotic'
'Mainecoon'
'Mainecoon'
'Mainecoon'
'Mainecoon'
'Mainecoon'
'Persia'
'Persia'
'Persia'
'Persia'
'Persia'
'Sphynx'
'Sphynx'
'Sphynx'
'Sphynx'
'Sphynx'
DLATIH =
1.0e+10 *
0.1114 1.0030 0.0106 0.0000
0.1114 1.0030 0.0106 0.0000
0.1114 1.0030 0.0106 0.0000
0.0959 1.0573 0.0153 0.0000
0.1114 1.0030 0.0106 0.0000
0.1276 2.5270 0.0104 0.0000
0.1276 2.5270 0.0104 0.0000
0.1276 2.5270 0.0104 0.0000
0.1276 2.5270 0.0104 0.0000
0.1276 2.5270 0.0104 0.0000
0.0669 0.6027 0.0046 0.0000
0.0669 0.6027 0.0046 0.0000
0.0669 0.6027 0.0046 0.0000
0.0669 0.6027 0.0046 0.0000
0.0669 0.6027 0.0046 0.0000
0.0893 0.2997 0.0045 0.0000
0.0893 0.2997 0.0045 0.0000
0.0893 0.2997 0.0045 0.0000
0.0893 0.2997 0.0045 0.0000
0.0893 0.2997 0.0045 0.0000
0.1419 3.0747 0.0114 0.0000
0.0732 1.1291 0.0145 0.0000
0.1418 1.8808 0.0081 0.0000
0.0892 1.3324 0.0200 0.0000
0.1418 0.9196 0.0120 0.0000
0.1114 0.8824 0.0063 0.0000
0.1114 0.8824 0.0063 0.0000
0.1114 0.8824 0.0063 0.0000
0.1114 0.8824 0.0063 0.0000
0.1421 1.1542 0.0027 0.0000
0.1099 1.0015 0.0114 0.0000
0.1099 1.0015 0.0114 0.0000
0.1099 1.0015 0.0114 0.0000
0.1099 1.0015 0.0114 0.0000
0.1099 1.0015 0.0114 0.0000
>> DLATIH2
DLATIH2 =
1.0e+10 *
0.1114 1.0030 0.0106 0.0000
0.1114 1.0030 0.0106 0.0000
0.1114 1.0030 0.0106 0.0000
0.0959 1.0573 0.0153 0.0000
0.1114 1.0030 0.0106 0.0000
0.1276 2.5270 0.0104 0.0000
0.1276 2.5270 0.0104 0.0000
0.1276 2.5270 0.0104 0.0000
0.1276 2.5270 0.0104 0.0000
0.1276 2.5270 0.0104 0.0000
0.0669 0.6027 0.0046 0.0000
0.0669 0.6027 0.0046 0.0000
0.0669 0.6027 0.0046 0.0000
0.0669 0.6027 0.0046 0.0000
0.0669 0.6027 0.0046 0.0000
0.0893 0.2997 0.0045 0.0000
0.0893 0.2997 0.0045 0.0000
0.0893 0.2997 0.0045 0.0000
0.0893 0.2997 0.0045 0.0000
0.0893 0.2997 0.0045 0.0000
0.1419 3.0747 0.0114 0.0000
0.0732 1.1291 0.0145 0.0000
0.1418 1.8808 0.0081 0.0000
0.0892 1.3324 0.0200 0.0000
0.1418 0.9196 0.0120 0.0000
0.1114 0.8824 0.0063 0.0000
0.1114 0.8824 0.0063 0.0000
0.1114 0.8824 0.0063 0.0000
0.1114 0.8824 0.0063 0.0000
0.1421 1.1542 0.0027 0.0000
0.1099 1.0015 0.0114 0.0000
0.1099 1.0015 0.0114 0.0000
0.1099 1.0015 0.0114 0.0000
0.1099 1.0015 0.0114 0.0000
0.1099 1.0015 0.0114 0.0000
Terlihat 0 tetapi sebanarnya nilainya ada......cb di lihat lebih detail:
>> DLATIH2(1,4)
ans =
1.6878e+04
Tidak ada komentar:
Posting Komentar