SHOGUN
v2.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
structure
MulticlassSOLabels.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) 2012 Fernando José Iglesias García
8
* Copyright (C) 2012 Fernando José Iglesias García
9
*/
10
11
#include <
shogun/structure/MulticlassSOLabels.h
>
12
13
using namespace
shogun;
14
15
CMulticlassSOLabels::CMulticlassSOLabels
()
16
:
CStructuredLabels
()
17
{
18
init();
19
}
20
21
CMulticlassSOLabels::CMulticlassSOLabels
(
SGVector< float64_t >
const
src)
22
:
CStructuredLabels
(src.vlen)
23
{
24
init();
25
26
m_num_classes =
SGVector< float64_t >::max
(src.
vector
, src.
vlen
) + 1;
27
for
( int32_t i = 0 ; i < src.
vlen
; ++i )
28
{
29
if
( src[i] < 0 || src[i] >= m_num_classes )
30
SG_ERROR
(
"Found label out of {0, 1, 2, ..., num_classes-1}"
);
31
else
32
add_label
(
new
CRealNumber
(src[i]) );
33
}
34
35
//TODO check that every class has at least one example
36
}
37
38
CMulticlassSOLabels::~CMulticlassSOLabels
()
39
{
40
}
41
42
void
CMulticlassSOLabels::init()
43
{
44
SG_ADD
(&m_num_classes,
"m_num_classes"
,
"The number of classes"
,
45
MS_NOT_AVAILABLE
);
46
47
m_num_classes = 0;
48
}
SHOGUN
Machine Learning Toolbox - Documentation