SHOGUN
3.2.1
首页
相关页面
模块
类
文件
文件列表
文件成员
全部
类
命名空间
文件
函数
变量
类型定义
枚举
枚举值
友元
宏定义
组
页
src
shogun
machine
MulticlassMachine.h
浏览该文件的文档.
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-2011 Soeren Sonnenburg
8
* Written (W) 2012 Fernando José Iglesias García and Sergey Lisitsyn
9
* Written (W) 2013 Shell Hu and Heiko Strathmann
10
* Copyright (C) 2012 Sergey Lisitsyn, Fernando José Iglesias Garcia
11
*/
12
13
#ifndef _MULTICLASSMACHINE_H___
14
#define _MULTICLASSMACHINE_H___
15
16
#include <
shogun/machine/BaseMulticlassMachine.h
>
17
#include <
shogun/lib/DynamicObjectArray.h
>
18
#include <
shogun/multiclass/MulticlassStrategy.h
>
19
#include <
shogun/labels/MulticlassLabels.h
>
20
#include <
shogun/labels/MulticlassMultipleOutputLabels.h
>
21
22
namespace
shogun
23
{
24
25
class
CFeatures;
26
class
CLabels;
27
29
class
CMulticlassMachine
:
public
CBaseMulticlassMachine
30
{
31
public
:
33
CMulticlassMachine
();
34
40
CMulticlassMachine
(
CMulticlassStrategy
* strategy,
CMachine
* machine,
CLabels
* labels);
41
43
virtual
~CMulticlassMachine
();
44
49
virtual
void
set_labels
(
CLabels
* lab);
50
57
inline
bool
set_machine
(int32_t num,
CMachine
* machine)
58
{
59
ASSERT
(num<m_machines->get_num_elements() && num>=0)
60
if
(machine != NULL && !
is_acceptable_machine
(machine))
61
SG_ERROR
(
"Machine %s is not acceptable by %s"
, machine->
get_name
(), this->
get_name
())
62
63
m_machines
->
set_element
(machine, num);
64
return
true
;
65
}
66
72
inline
CMachine
*
get_machine
(int32_t num)
const
73
{
74
return
(
CMachine
*)
m_machines
->
get_element_safe
(num);
75
}
76
81
virtual
CBinaryLabels
*
get_submachine_outputs
(int32_t i);
82
88
virtual
float64_t
get_submachine_output
(int32_t i, int32_t num);
89
94
virtual
CMulticlassLabels
*
apply_multiclass
(
CFeatures
* data=NULL);
95
100
virtual
CMulticlassMultipleOutputLabels
*
apply_multiclass_multiple_output
(
CFeatures
* data=NULL, int32_t n_outputs=5);
101
106
virtual
float64_t
apply_one
(int32_t vec_idx);
107
112
inline
CMulticlassStrategy
*
get_multiclass_strategy
()
const
113
{
114
SG_REF
(
m_multiclass_strategy
);
115
return
m_multiclass_strategy
;
116
}
117
122
inline
CRejectionStrategy
*
get_rejection_strategy
()
const
123
{
124
return
m_multiclass_strategy
->
get_rejection_strategy
();
125
}
126
131
inline
void
set_rejection_strategy
(
CRejectionStrategy
* rejection_strategy)
132
{
133
m_multiclass_strategy
->
set_rejection_strategy
(rejection_strategy);
134
}
135
137
virtual
const
char
*
get_name
()
const
138
{
139
return
"MulticlassMachine"
;
140
}
141
143
inline
EProbHeuristicType
get_prob_heuris
()
144
{
145
return
m_multiclass_strategy
->
get_prob_heuris_type
();
146
}
147
151
inline
void
set_prob_heuris
(
EProbHeuristicType
prob_heuris)
152
{
153
m_multiclass_strategy
->
set_prob_heuris_type
(prob_heuris);
154
}
155
156
protected
:
158
void
init_strategy
();
159
161
void
clear_machines
();
162
164
virtual
bool
train_machine
(
CFeatures
* data = NULL);
165
167
virtual
bool
init_machine_for_train
(
CFeatures
* data) = 0;
168
170
virtual
bool
init_machines_for_apply
(
CFeatures
* data) = 0;
171
173
virtual
bool
is_ready
() = 0;
174
176
virtual
CMachine
*
get_machine_from_trained
(
CMachine
* machine) = 0;
177
179
virtual
int32_t
get_num_rhs_vectors
() = 0;
180
185
virtual
void
add_machine_subset
(
SGVector<index_t>
subset) = 0;
186
188
virtual
void
remove_machine_subset
() = 0;
189
191
virtual
bool
is_acceptable_machine
(
CMachine
*machine)
192
{
193
return
true
;
194
}
195
196
private
:
197
199
void
register_parameters();
200
201
protected
:
203
CMulticlassStrategy
*
m_multiclass_strategy
;
204
206
CMachine
*
m_machine
;
207
};
208
}
209
#endif
SHOGUN
机器学习工具包 - 项目文档