SHOGUN
v3.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
machine
Machine.h
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) 1999-2009 Soeren Sonnenburg
8
* Written (W) 2011-2012 Heiko Strathmann
9
* Copyright (C) 1999-2009 Fraunhofer Institute FIRST and Max-Planck-Society
10
*/
11
12
#ifndef _MACHINE_H__
13
#define _MACHINE_H__
14
15
#include <
shogun/lib/common.h
>
16
#include <
shogun/base/SGObject.h
>
17
#include <
shogun/labels/Labels.h
>
18
#include <
shogun/labels/BinaryLabels.h
>
19
#include <
shogun/labels/RegressionLabels.h
>
20
#include <
shogun/labels/MulticlassLabels.h
>
21
#include <
shogun/labels/StructuredLabels.h
>
22
#include <
shogun/labels/LatentLabels.h
>
23
#include <
shogun/features/Features.h
>
24
25
namespace
shogun
26
{
27
28
class
CFeatures;
29
class
CLabels;
30
class
CMath;
31
33
enum
EMachineType
34
{
35
CT_NONE
= 0,
36
CT_LIGHT
= 10,
37
CT_LIGHTONECLASS
= 11,
38
CT_LIBSVM
= 20,
39
CT_LIBSVMONECLASS
=30,
40
CT_LIBSVMMULTICLASS
=40,
41
CT_MPD
= 50,
42
CT_GPBT
= 60,
43
CT_CPLEXSVM
= 70,
44
CT_PERCEPTRON
= 80,
45
CT_KERNELPERCEPTRON
= 90,
46
CT_LDA
= 100,
47
CT_LPM
= 110,
48
CT_LPBOOST
= 120,
49
CT_KNN
= 130,
50
CT_SVMLIN
=140,
51
CT_KERNELRIDGEREGRESSION
= 150,
52
CT_GNPPSVM
= 160,
53
CT_GMNPSVM
= 170,
54
CT_SVMPERF
= 200,
55
CT_LIBSVR
= 210,
56
CT_SVRLIGHT
= 220,
57
CT_LIBLINEAR
= 230,
58
CT_KMEANS
= 240,
59
CT_HIERARCHICAL
= 250,
60
CT_SVMOCAS
= 260,
61
CT_WDSVMOCAS
= 270,
62
CT_SVMSGD
= 280,
63
CT_MKLMULTICLASS
= 290,
64
CT_MKLCLASSIFICATION
= 300,
65
CT_MKLONECLASS
= 310,
66
CT_MKLREGRESSION
= 320,
67
CT_SCATTERSVM
= 330,
68
CT_DASVM
= 340,
69
CT_LARANK
= 350,
70
CT_DASVMLINEAR
= 360,
71
CT_GAUSSIANNAIVEBAYES
= 370,
72
CT_AVERAGEDPERCEPTRON
= 380,
73
CT_SGDQN
= 390,
74
CT_CONJUGATEINDEX
= 400,
75
CT_LINEARRIDGEREGRESSION
= 410,
76
CT_LEASTSQUARESREGRESSION
= 420,
77
CT_QDA
= 430,
78
CT_NEWTONSVM
= 440,
79
CT_GAUSSIANPROCESSREGRESSION
= 450,
80
CT_LARS
= 460,
81
CT_MULTICLASS
= 470,
82
CT_DIRECTORLINEAR
= 480,
83
CT_DIRECTORKERNEL
= 490,
84
CT_LIBQPSOSVM
= 500,
85
CT_PRIMALMOSEKSOSVM
= 510,
86
CT_CCSOSVM
= 520,
87
CT_GAUSSIANPROCESSBINARY
= 530,
88
CT_GAUSSIANPROCESSMULTICLASS
= 540,
89
CT_BAGGING
90
};
91
93
enum
ESolverType
94
{
95
ST_AUTO
=0,
96
ST_CPLEX
=1,
97
ST_GLPK
=2,
98
ST_NEWTON
=3,
99
ST_DIRECT
=4,
100
ST_ELASTICNET
=5,
101
ST_BLOCK_NORM
=6
102
};
103
105
enum
EProblemType
106
{
107
PT_BINARY
= 0,
108
PT_REGRESSION
= 1,
109
PT_MULTICLASS
= 2,
110
PT_STRUCTURED
= 3,
111
PT_LATENT
= 4
112
};
113
114
#define MACHINE_PROBLEM_TYPE(PT) \
115
\
118
virtual EProblemType get_machine_problem_type() const { return PT; }
119
137
class
CMachine :
public
CSGObject
138
{
139
public
:
141
CMachine
();
142
144
virtual
~CMachine
();
145
155
virtual
bool
train
(CFeatures* data=NULL);
156
163
virtual
CLabels*
apply
(CFeatures* data=NULL);
164
166
virtual
CBinaryLabels*
apply_binary
(CFeatures* data=NULL);
168
virtual
CRegressionLabels*
apply_regression
(CFeatures* data=NULL);
170
virtual
CMulticlassLabels*
apply_multiclass
(CFeatures* data=NULL);
172
virtual
CStructuredLabels*
apply_structured
(CFeatures* data=NULL);
174
virtual
CLatentLabels*
apply_latent
(CFeatures* data=NULL);
175
180
virtual
void
set_labels
(CLabels* lab);
181
186
virtual
CLabels*
get_labels
();
187
192
void
set_max_train_time
(
float64_t
t);
193
198
float64_t
get_max_train_time
();
199
204
virtual
EMachineType
get_classifier_type
();
205
210
void
set_solver_type
(
ESolverType
st);
211
216
ESolverType
get_solver_type
();
217
223
virtual
void
set_store_model_features
(
bool
store_model);
224
233
virtual
bool
train_locked
(SGVector<index_t> indices)
234
{
235
SG_ERROR
(
"train_locked(SGVector<index_t>) is not yet implemented "
236
"for %s\n"
,
get_name
());
237
return
false
;
238
}
239
241
virtual
float64_t
apply_one
(int32_t i)
242
{
243
SG_NOTIMPLEMENTED
244
return
0.0;
245
}
246
252
virtual
CLabels
*
apply_locked
(
SGVector<index_t>
indices);
253
255
virtual
CBinaryLabels
*
apply_locked_binary
(
256
SGVector<index_t>
indices);
258
virtual
CRegressionLabels
*
apply_locked_regression
(
259
SGVector<index_t>
indices);
261
virtual
CMulticlassLabels
*
apply_locked_multiclass
(
262
SGVector<index_t>
indices);
264
virtual
CStructuredLabels
*
apply_locked_structured
(
265
SGVector<index_t>
indices);
267
virtual
CLatentLabels
*
apply_locked_latent
(
268
SGVector<index_t>
indices);
269
278
virtual
void
data_lock
(
CLabels
* labs,
CFeatures
* features);
279
281
virtual
void
post_lock
(
CLabels
* labs,
CFeatures
* features) { };
282
284
virtual
void
data_unlock
();
285
287
virtual
bool
supports_locking
()
const
{
return
false
; }
288
290
bool
is_data_locked
()
const
{
return
m_data_locked
; }
291
293
virtual
EProblemType
get_machine_problem_type
()
const
294
{
295
SG_NOTIMPLEMENTED
296
return
PT_BINARY
;
297
}
298
299
virtual
const
char
*
get_name
()
const
{
return
"Machine"
; }
300
301
protected
:
312
virtual
bool
train_machine
(CFeatures* data=NULL)
313
{
314
SG_ERROR
(
"train_machine is not yet implemented for %s!\n"
,
315
get_name
());
316
return
false
;
317
}
318
329
virtual
void
store_model_features
()
330
{
331
SG_ERROR
(
"Model storage and therefore unlocked Cross-Validation and"
332
" Model-Selection is not supported for %s. Locked may"
333
" work though.\n"
,
get_name
());
334
}
335
342
virtual
bool
is_label_valid
(CLabels *lab)
const
343
{
344
return
true
;
345
}
346
348
virtual
bool
train_require_labels
()
const
{
return
true
; }
349
350
protected
:
352
float64_t
m_max_train_time
;
353
355
CLabels
*
m_labels
;
356
358
ESolverType
m_solver_type
;
359
361
bool
m_store_model_features
;
362
364
bool
m_data_locked
;
365
};
366
}
367
#endif // _MACHINE_H__
SHOGUN
Machine Learning Toolbox - Documentation