-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.m
73 lines (38 loc) · 1.1 KB
/
main.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
close all
clear
clc
%Load generated synthetic Data
load('SyntheticData.mat');
Labels=[Data.Bags(:).Label];
Pos=find(Labels+1);
Neg=find(1-Labels);
Ratio=0.7;
% Split Data into Train and Test Data
TrainPosIdx=round(0.6*length(Pos));
TrainNegIdx=round(0.6*length(Neg));
Test= [Pos(TrainPosIdx+1:end) Neg(TrainNegIdx+1:end)];
Train= [Pos(1:TrainPosIdx) Neg(1:TrainNegIdx)];
TrainData.Bags=Data.Bags(Train);
TrainData.NbBags=length(Train);
TestData.Bags=Data.Bags(Test);
TestData.NbBags=length(Test);
Insts=[];
for i=1:TrainData.NbBags
Insts=[Insts;TrainData.Bags(i).Insts];
end
scatter(Insts(:,1),Insts(:,2))
% Compute Distance between instances
for i=1:length(Insts)
for j=1:length(Insts)
Dists(i,j)=sqrt(sum( (Insts(i,:)-Insts(j,:)).^2 ));
end
end
% Compute Lambda and Beta
SortedDists=sort(Dists,2);
Best_Sig=mean(SortedDists(:,20));
lambda=1/(Best_Sig^2);
beta=lambda;
% Train
[IPs, W ]=MILIS_Train(TrainData,TestData,beta,lambda);
% Test
[Acc,Conf,LblDiff]=MILIS_Test(TestData,TrainData,IPs,W,lambda)