SHOGUN  3.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Labels.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) 1999-2009 Soeren Sonnenburg
8  * Written (W) 1999-2008 Gunnar Raetsch
9  * Written (W) 2011-2012 Heiko Strathmann
10  * Copyright (C) 1999-2009 Fraunhofer Institute FIRST and Max-Planck-Society
11  */
12 
13 #include <shogun/labels/Labels.h>
14 #include <shogun/lib/common.h>
15 #include <shogun/io/SGIO.h>
16 
17 using namespace shogun;
18 
20  : CSGObject()
21 {
22  init();
23 }
24 
26 {
28 }
29 
30 void CLabels::init()
31 {
32  SG_ADD((CSGObject **)&m_subset_stack, "subset_stack",
33  "Current subset stack", MS_NOT_AVAILABLE);
34 
37 }
38 
40 {
41  m_subset_stack->add_subset(subset);
42 }
43 
45 {
47 }
48 
50 {
52 }
53 
55 {
57 }
58 
60 {
62  int32_t real_num = m_subset_stack->subset_idx_conversion(idx);
63  return m_current_values.vector[real_num];
64 }
65 
66 void CLabels::set_value(float64_t value, int32_t idx)
67 {
68 
69  REQUIRE(m_current_values.vector, "%s::set_value(%f, %d): No values vector"
70  " set!\n", get_name(), value, idx);
71  REQUIRE(get_num_labels(), "%s::set_value(%f, %d): Number of values is "
72  "zero!\n", get_name(), value, idx);
73 
74  int32_t real_num = m_subset_stack->subset_idx_conversion(idx);
75  m_current_values.vector[real_num] = value;
76 }
77 
79 {
81  {
82  SG_ERROR("length of value values should match number of labels or"
83  " have zero length (len(labels)=%d, len(values)=%d)\n",
84  get_num_labels(), values.vlen);
85  }
86 
87  m_current_values = values;
88 }
89 
91 {
92  return m_current_values;
93 }

SHOGUN Machine Learning Toolbox - Documentation