forked from iqiukp/SVDD-MATLAB
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo_nSVDD.m
34 lines (28 loc) · 923 Bytes
/
demo_nSVDD.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
%{
Demonstration of SVDD model training with both positive and negative samples.
%}
clc
clear all
close all
addpath(genpath(pwd))
% training data and test data
[data, label] = DataSet.generate('dim', 2, '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);
% 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);
exportgraphics(gcf, '.\img\模板.emf','Resolution', 600)