SHOGUN
v1.1.0
Main Page
Related Pages
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
src
shogun
machine
Machine.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) 1999-2009 Soeren Sonnenburg
8
* Copyright (C) 1999-2009 Fraunhofer Institute FIRST and Max-Planck-Society
9
*/
10
11
#include <
shogun/machine/Machine.h
>
12
#include <
shogun/base/Parameter.h
>
13
#include <
shogun/mathematics/Math.h
>
14
15
using namespace
shogun;
16
17
CMachine::CMachine
() :
CSGObject
(), max_train_time(0), labels(NULL),
18
solver_type(
ST_AUTO
)
19
{
20
m_parameters
->
add
(&
max_train_time
,
"max_train_time"
,
21
"Maximum training time."
);
22
m_parameters
->
add
((
machine_int_t
*) &
solver_type
,
"solver_type"
);
23
m_parameters
->
add
((
CSGObject
**) &
labels
,
"labels"
);
24
m_parameters
->
add
(&
m_store_model_features
,
"store_model_features"
,
25
"Should feature data of model be stored after training?"
);
26
27
m_store_model_features
=
false
;
28
}
29
30
CMachine::~CMachine
()
31
{
32
SG_UNREF
(
labels
);
33
}
34
35
bool
CMachine::train
(
CFeatures
* data)
36
{
37
bool
result =
train_machine
(data);
38
39
if
(
m_store_model_features
)
40
store_model_features
();
41
42
return
result;
43
}
44
45
float64_t
CMachine::apply
(int32_t num)
46
{
47
SG_NOTIMPLEMENTED
;
48
return
CMath::INFTY
;
49
}
50
51
bool
CMachine::load
(FILE* srcfile)
52
{
53
ASSERT
(srcfile);
54
return
false
;
55
}
56
57
bool
CMachine::save
(FILE* dstfile)
58
{
59
ASSERT
(dstfile);
60
return
false
;
61
}
62
63
void
CMachine::set_labels
(
CLabels
* lab)
64
{
65
SG_UNREF
(
labels
);
66
SG_REF
(lab);
67
labels
= lab;
68
}
69
70
CLabels
*
CMachine::get_labels
()
71
{
72
SG_REF
(
labels
);
73
return
labels
;
74
}
75
76
float64_t
CMachine::get_label
(int32_t i)
77
{
78
if
(!
labels
)
79
SG_ERROR
(
"No Labels assigned\n"
);
80
81
return
labels
->
get_label
(i);
82
}
83
84
void
CMachine::set_max_train_time
(
float64_t
t)
85
{
86
max_train_time
= t;
87
}
88
89
float64_t
CMachine::get_max_train_time
()
90
{
91
return
max_train_time
;
92
}
93
94
EClassifierType
CMachine::get_classifier_type
()
95
{
96
return
CT_NONE
;
97
}
98
99
void
CMachine::set_solver_type
(
ESolverType
st)
100
{
101
solver_type
= st;
102
}
103
104
ESolverType
CMachine::get_solver_type
()
105
{
106
return
solver_type
;
107
}
108
109
void
CMachine::set_store_model_features
(
bool
store_model)
110
{
111
m_store_model_features
= store_model;
112
}
113
114
SHOGUN
Machine Learning Toolbox - Documentation