-
Notifications
You must be signed in to change notification settings - Fork 22
/
demo_DimReduPCA.m
36 lines (30 loc) · 960 Bytes
/
demo_DimReduPCA.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
%{
Demonstration of SVDD model training with PCA.
%}
clc
close all
addpath(genpath(pwd))
ocdata = BinaryDataset( 'shape', 'circle',...
'dimensionality', 3,...
'number', [200, 200],...
'display', 'on', ...
'noise', 0.1,...
'ratio', 0.3);
[data, label] = ocdata.generate;
[trainData, trainLabel, testData, testLabel] = ocdata.partition;
% parameter setting
cost = 0.9;
kernel = BaseKernel('type', 'gaussian', 'gamma', 0.5);
svddParameter = struct('cost', cost,...
'kernelFunc', kernel,...
'PCA', 2);
% creat an SVDD object
svdd = BaseSVDD(svddParameter);
% train SVDD model
svdd.train(trainData, trainLabel);
% test SVDD model
results = svdd.test(testData, testLabel);
% Visualization
svplot = SvddVisualization();
svplot.boundary(svdd);
svplot.distance(svdd, results);