forked from iqiukp/SVDD-MATLAB
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo_nSVDD_PCA.m
33 lines (28 loc) · 870 Bytes
/
demo_nSVDD_PCA.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
%{
Demonstration of SVDD model training with PCA.
%}
clc
clear all
close all
addpath(genpath(pwd))
% training data and test data
[data, label] = DataSet.generate('dim', 3, 'num', [200, 200], 'display', 'off');
[trainData, trainLabel, testData, testLabel] = DataSet.partition(data, label, 'type', 'hybrid');
% parameter setting
kernel = Kernel('type', 'gaussian', 'gamma', 0.04);
cost = 0.3;
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.ROC(svdd);
svplot.distance(svdd, results);
svplot.testDataWithBoundary(svdd, results);