SHOGUN
3.2.1
首页
相关页面
模块
类
文件
文件列表
文件成员
全部
类
命名空间
文件
函数
变量
类型定义
枚举
枚举值
友元
宏定义
组
页
src
shogun
multiclass
MulticlassStrategy.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) 2012 Chiyuan Zhang
8
* Written (W) 2013 Shell Hu and Heiko Strathmann
9
* Copyright (C) 2012 Chiyuan Zhang
10
*/
11
12
#ifndef MULTICLASSSTRATEGY_H__
13
#define MULTICLASSSTRATEGY_H__
14
15
#include <
shogun/base/SGObject.h
>
16
#include <
shogun/labels/BinaryLabels.h
>
17
#include <
shogun/labels/MulticlassLabels.h
>
18
#include <
shogun/multiclass/RejectionStrategy.h
>
19
#include <
shogun/mathematics/Statistics.h
>
20
21
namespace
shogun
22
{
23
34
enum
EProbHeuristicType
35
{
36
PROB_HEURIS_NONE
= 0,
37
OVA_NORM
= 1,
38
OVA_SOFTMAX
= 2,
39
OVO_PRICE
= 3,
40
OVO_HASTIE
= 4,
41
OVO_HAMAMURA
= 5
42
};
43
47
class
CMulticlassStrategy
:
public
CSGObject
48
{
49
public
:
51
CMulticlassStrategy
();
52
56
CMulticlassStrategy
(
EProbHeuristicType
prob_heuris);
57
59
virtual
~CMulticlassStrategy
() {}
60
62
virtual
const
char
*
get_name
()
const
63
{
64
return
"MulticlassStrategy"
;
65
};
66
68
void
set_num_classes
(int32_t num_classes)
69
{
70
m_num_classes
= num_classes;
71
}
72
74
int32_t
get_num_classes
()
const
75
{
76
return
m_num_classes
;
77
}
78
80
CRejectionStrategy
*
get_rejection_strategy
()
81
{
82
SG_REF
(
m_rejection_strategy
);
83
return
m_rejection_strategy
;
84
}
85
87
void
set_rejection_strategy
(
CRejectionStrategy
*rejection_strategy)
88
{
89
SG_REF
(rejection_strategy);
90
SG_UNREF
(
m_rejection_strategy
);
91
m_rejection_strategy
= rejection_strategy;
92
}
93
95
virtual
void
train_start
(
CMulticlassLabels
*orig_labels,
CBinaryLabels
*train_labels);
96
98
virtual
bool
train_has_more
()=0;
99
103
virtual
SGVector<int32_t>
train_prepare_next
();
104
106
virtual
void
train_stop
();
107
111
virtual
int32_t
decide_label
(
SGVector<float64_t>
outputs)=0;
112
117
virtual
SGVector<index_t>
decide_label_multiple_output
(
SGVector<float64_t>
outputs, int32_t n_outputs)
118
{
119
SG_NOTIMPLEMENTED
120
return
SGVector<index_t>
();
121
}
122
125
virtual
int32_t
get_num_machines
()=0;
126
128
EProbHeuristicType
get_prob_heuris_type
()
129
{
130
return
m_prob_heuris
;
131
}
132
136
void
set_prob_heuris_type
(
EProbHeuristicType
prob_heuris)
137
{
138
m_prob_heuris
= prob_heuris;
139
}
140
146
virtual
void
rescale_outputs
(
SGVector<float64_t>
outputs)
147
{
148
SG_NOTIMPLEMENTED
149
}
150
158
virtual
void
rescale_outputs
(
SGVector<float64_t>
outputs,
159
const
SGVector<float64_t>
As,
const
SGVector<float64_t>
Bs)
160
{
161
SG_NOTIMPLEMENTED
162
}
163
164
private
:
166
void
init();
167
168
protected
:
169
170
CRejectionStrategy
*
m_rejection_strategy
;
171
CBinaryLabels
*
m_train_labels
;
172
CMulticlassLabels
*
m_orig_labels
;
173
int32_t
m_train_iter
;
174
int32_t
m_num_classes
;
175
EProbHeuristicType
m_prob_heuris
;
176
};
177
178
}
// namespace shogun
179
180
#endif
/* end of include guard: MULTICLASSSTRATEGY_H__ */
181
SHOGUN
机器学习工具包 - 项目文档