-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathexampleKDLOR.m
32 lines (23 loc) · 955 Bytes
/
exampleKDLOR.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
addpath ../Algorithms/
% Load the different partitions of the dataset
load ../../exampledata/1-holdout/toy/matlab/train_toy.0
load ../../exampledata/1-holdout/toy/matlab/test_toy.0
% "patterns" refers to the input variables and targets to the output one
train.patterns = train_toy(:,1:end-1);
train.targets = train_toy(:,end);
test.patterns = test_toy(:,1:end-1);
test.targets = test_toy(:,end);
% Create the algorithm object
kdlorAlgorithm = KDLOR('kernelType','rbf','optimizationMethod','quadprog');
% Parameter C (Cost)
param.C = 10;
% Parameter k (kernel width)
param.k = 0.1;
% Parameter u (to avoid singularities)
param.u = 0.001;
% Running the algorithm
info = kdlorAlgorithm.runAlgorithm(train,test,param);
accTrain = sum(train.targets==info.predictedTrain)/size(train.targets,1);
accTest = sum(test.targets==info.predictedTest)/size(test.targets,1);
% Reporting accuracy
fprintf('Accuracy Train %f, Accuracy Test %f\n',accTrain,accTest);