-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathIrisHoldOut.m
57 lines (45 loc) · 1.1 KB
/
IrisHoldOut.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
clc;
clear all;
close all;
load iris_dataset.mat;
X=irisInputs';
Y=irisTargets';
for i=1:size(Y,1)
[~,l(:,i)]=max(Y(i,:));%index at which the maximum value of Y(i) occurs
end
c=cvpartition(l,'HoldOut',0.3);
trIdx=c.training;
teidx=c.test;
xtr=X(trIdx,:);
ytr=Y(trIdx,:);
xte=X(teidx,:);
yte=Y(teidx,:);
xtrain=xtr;
ytrain=ytr;
xtest=xte;
ytest=yte;
tic
NumberofHiddenNeurons=30;
NumberofTrainingData=size(xtrain,1);
NumberofTestingData=size(xtest,1);
NumberofInputNeurons=size(xtrain,2);
randommat=randn(NumberofInputNeurons+1,NumberofHiddenNeurons);
tempH=[ones(size(xtrain,1),1) xtrain]*randommat;
H=tanh(tempH);
[m,n]=size(H);
OutputWeight=pinv(H)*ytrain;
testH=[ones(size(xtest,1),1) xtest]*randommat;
Ht=tanh(testH);
yn=Ht*OutputWeight;
for i=1:size(xtest,1)
[~, lp(:,i)]=max(yn(i,:));
[~, lt(:,i)]=max(ytest(i,:));
end
[cmt,order]=confusionmat(lp,lt);
display(cmt);
display(order);
%summ=sum(cmt(:));
%test_acc=(cmt(1,1)+cmt(2,2)/summ)*100;
%test_sen=(cmt(1,1)/(cmt(1,1)+cmt(1,2)))*100;
%test_spe=(cmt(2,2)/(cmt(2,2)+cmt(2,1)))*100;
toc