SHOGUN
v2.0.0
Main Page
Related Pages
Modules
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
src
shogun
structure
DualLibQPBMSOSVM.cpp
Go to the documentation of this file.
1
/*
2
* This program is free software; you can redistribute it and/or modify
3
* it under the terms of the GNU General Public License as published by
4
* the Free Software Foundation; either version 3 of the License, or
5
* (at your option) any later version.
6
*
7
* Written (W) 2012 Michal Uricar
8
* Copyright (C) 2012 Michal Uricar
9
*/
10
11
#include <
shogun/structure/DualLibQPBMSOSVM.h
>
12
#include <
shogun/structure/libppbm.h
>
13
#include <
shogun/structure/libp3bm.h
>
14
15
using namespace
shogun;
16
17
CDualLibQPBMSOSVM::CDualLibQPBMSOSVM
()
18
:
CLinearStructuredOutputMachine
()
19
{
20
}
21
22
CDualLibQPBMSOSVM::CDualLibQPBMSOSVM
(
23
CStructuredModel
* model,
24
CLossFunction
* loss,
25
CStructuredLabels
* labs,
26
float64_t
_lambda,
27
SGVector< float64_t >
W)
28
:
CLinearStructuredOutputMachine
(model, loss, labs)
29
{
30
set_TolRel
(0.001);
31
set_TolAbs
(0.0);
32
set_BufSize
(1000);
33
set_lambda
(_lambda);
34
set_cleanICP
(
true
);
35
set_cleanAfter
(10);
36
set_K
(0.4);
37
set_Tmax
(100);
38
set_cp_models
(1);
39
set_verbose
(
true
);
40
set_solver
(
BMRM
);
41
42
// get dimension of w
43
uint32_t nDim=this->
m_model
->
get_dim
();
44
45
// Check for initial solution
46
if
(W.
vlen
==0)
47
{
48
m_w
=
SGVector< float64_t >
(nDim);
49
50
m_w
.
zero
();
51
}
52
else
53
{
54
set_w
(W);
55
}
56
57
init();
58
}
59
60
CDualLibQPBMSOSVM::~CDualLibQPBMSOSVM
()
61
{
62
}
63
64
void
CDualLibQPBMSOSVM::init()
65
{
66
SG_ADD
(&m_TolRel,
"m_TolRel"
,
"Relative tolerance"
,
MS_NOT_AVAILABLE
);
67
SG_ADD
(&m_TolAbs,
"m_TolAbs"
,
"Absolute tolerance"
,
MS_NOT_AVAILABLE
);
68
SG_ADD
(&m_BufSize,
"m_BuffSize"
,
"Size of CP Buffer"
,
MS_AVAILABLE
);
69
SG_ADD
(&m_lambda,
"m_lambda"
,
"Regularization constant lambda"
,
70
MS_AVAILABLE
);
71
SG_ADD
(&m_cleanICP,
"m_cleanICP"
,
"Inactive cutting plane removal flag"
,
72
MS_AVAILABLE
);
73
SG_ADD
(&m_cleanAfter,
74
"m_cleanAfter"
,
75
"Number of inactive iterations after which ICP will be removed"
,
76
MS_NOT_AVAILABLE
);
77
SG_ADD
(&m_K,
"m_K"
,
"Parameter K"
,
MS_NOT_AVAILABLE
);
78
SG_ADD
(&m_Tmax,
"m_Tmax"
,
"Parameter Tmax"
,
MS_AVAILABLE
);
79
SG_ADD
(&m_cp_models,
"m_cp_models"
,
"Number of cutting plane models"
,
80
MS_AVAILABLE
);
81
SG_ADD
(&m_verbose,
"m_verbose"
,
"Verbosity flag"
,
MS_AVAILABLE
);
82
}
83
84
bool
CDualLibQPBMSOSVM::train_machine
(
CFeatures
* data)
85
{
86
if
(data)
87
set_features
(data);
88
89
// call the solver
90
switch
(m_solver)
91
{
92
case
BMRM
:
93
m_result=
svm_bmrm_solver
(
m_model
,
m_w
.
vector
, m_TolRel, m_TolAbs,
94
m_lambda, m_BufSize, m_cleanICP, m_cleanAfter, m_K, m_Tmax,
95
m_verbose);
96
break
;
97
case
PPBMRM
:
98
m_result=
svm_ppbm_solver
(
m_model
,
m_w
.
vector
, m_TolRel, m_TolAbs,
99
m_lambda, m_BufSize, m_cleanICP, m_cleanAfter, m_K, m_Tmax,
100
m_verbose);
101
break
;
102
case
P3BMRM
:
103
m_result=
svm_p3bm_solver
(
m_model
,
m_w
.
vector
, m_TolRel, m_TolAbs,
104
m_lambda, m_BufSize, m_cleanICP, m_cleanAfter, m_K, m_Tmax,
105
m_cp_models, m_verbose);
106
break
;
107
}
108
109
if
(m_result.
exitflag
==1)
110
{
111
return
true
;
112
}
113
else
114
{
115
return
false
;
116
}
117
}
SHOGUN
Machine Learning Toolbox - Documentation