-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathESSVDDdemo.m
37 lines (32 loc) · 1.71 KB
/
ESSVDDdemo.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
% This is a sample demo code for Subspace Support Vector Data Description
% Please contact [email protected] for any errors/bugs
clc
close all
clear
addpath(pwd);
%%Generate Random Data
noOfTrainData = 500; noOfTestData = 100;
D= 5; %Original dimentionality of data
Traindata = rand(D,noOfTrainData); %Generate training data
%Training labels (all +1s) are not needed.
testlabels = -ones(noOfTestData,1);
perm = randperm(noOfTestData);
positiveSamples = floor(noOfTestData/2);
testlabels(perm(1:positiveSamples))=1; % test labels, +1 for target, -1 for outliers
Testdata= rand(D,noOfTestData); %Generate testing data
%Possible inputs to essvddtrain
% The first input argument is the Training (target) data
%other options are
% 'maxIter' :Maximim iteraions, Default=100
% 'C' :Value of hyperparameter C, Default=0.1
% 'd' :data in lower dimension, make sure that input d<D, Default=1,
% 'eta' :Used as step size for gradient, Default=0.1
% 'psi' :regularization term, Default=0 i.e., No regularization term
% :Other options for psi are 1,2,3 (Please refer to paper for more details)
% 'upsilon' :regularization term, Default=0 i.e., No regularization term
% :Other options for upsilon are 1,2,3 (Please refer to paper for more details)
% 'B' :Controling the importance of regularization term, Default=0.1
% 'npt' :1 for Non-linear Projection Trick (NPT)-based non-linear Subspace-SVDD (Default=0, linear)
% 's' :Hyperparameter for the kernel inside NPT.
essvddmodel=essvddtrain(Traindata,'C',0.1,'d',4,'eta',0.02,'B',0.001,'psi',2);
[predicted_labels,accuracy,sensitivity,specificity]=essvddtest(Testdata,testlabels,essvddmodel);