SHOGUN  v2.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 
12 
13 using namespace shogun;
14 
17 {
18  init();
19 }
20 
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 
39 {
40 }
41 
42 void CMulticlassSOLabels::init()
43 {
44  SG_ADD(&m_num_classes, "m_num_classes", "The number of classes",
46 
47  m_num_classes = 0;
48 }

SHOGUN Machine Learning Toolbox - Documentation