SHOGUN
3.2.1
首页
相关页面
模块
类
文件
文件列表
文件成员
全部
类
命名空间
文件
函数
变量
类型定义
枚举
枚举值
友元
宏定义
组
页
src
shogun
multiclass
MulticlassStrategy.cpp
浏览该文件的文档.
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
#include <
shogun/multiclass/MulticlassStrategy.h
>
13
#include <
shogun/mathematics/Math.h
>
14
15
using namespace
shogun;
16
17
18
CMulticlassStrategy::CMulticlassStrategy
()
19
:
CSGObject
()
20
{
21
init();
22
}
23
24
CMulticlassStrategy::CMulticlassStrategy
(
EProbHeuristicType
prob_heuris)
25
:
CSGObject
()
26
{
27
init();
28
29
m_prob_heuris
=prob_heuris;
30
}
31
32
void
CMulticlassStrategy::init()
33
{
34
m_rejection_strategy
=NULL;
35
m_train_labels
=NULL;
36
m_orig_labels
=NULL;
37
m_train_iter
=0;
38
m_prob_heuris
=
PROB_HEURIS_NONE
;
39
m_num_classes
=0;
40
41
SG_ADD
((
CSGObject
**)&
m_rejection_strategy
,
"rejection_strategy"
,
"Strategy of rejection"
,
MS_NOT_AVAILABLE
);
42
SG_ADD
(&
m_num_classes
,
"num_classes"
,
"Number of classes"
,
MS_NOT_AVAILABLE
);
43
SG_ADD
((
machine_int_t
*)&
m_prob_heuris
,
"prob_heuris"
,
"Probability estimation heuristics"
,
MS_NOT_AVAILABLE
);
44
}
45
46
void
CMulticlassStrategy::train_start
(
CMulticlassLabels
*orig_labels,
CBinaryLabels
*train_labels)
47
{
48
if
(
m_train_labels
!= NULL)
49
SG_ERROR
(
"Stop the previous training task before starting a new one!"
)
50
SG_REF
(train_labels);
51
m_train_labels
=train_labels;
52
SG_REF
(orig_labels);
53
m_orig_labels
=orig_labels;
54
m_train_iter
=0;
55
}
56
57
SGVector<int32_t>
CMulticlassStrategy::train_prepare_next
()
58
{
59
m_train_iter
++;
60
return
SGVector<int32_t>
();
61
}
62
63
void
CMulticlassStrategy::train_stop
()
64
{
65
SG_UNREF
(
m_train_labels
);
66
SG_UNREF
(
m_orig_labels
);
67
m_train_labels
= NULL;
68
m_orig_labels
= NULL;
69
}
SHOGUN
机器学习工具包 - 项目文档