SHOGUN  3.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MultilabelLabels.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2013 Zuse-Institute-Berlin (ZIB)
3  * Copyright (C) 2013-2014 Thoralf Klein
4  * Written (W) 2013-2014 Thoralf Klein
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions are met:
9  *
10  * 1. Redistributions of source code must retain the above copyright notice, this
11  * list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright notice,
13  * this list of conditions and the following disclaimer in the documentation
14  * and/or other materials provided with the distribution.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
20  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  *
27  * The views and conclusions contained in the software and documentation are those
28  * of the authors and should not be interpreted as representing official policies,
29  * either expressed or implied, of the Shogun Development Team.
30  */
31 
32 #ifndef _MULTILABEL_LABELS__H__
33 #define _MULTILABEL_LABELS__H__
34 
35 #include <shogun/lib/config.h>
36 
37 #include <shogun/lib/common.h>
39 #include <shogun/labels/Labels.h>
40 #include <shogun/lib/SGVector.h>
41 #include <shogun/lib/SGMatrix.h>
42 
43 namespace shogun
44 {
45 
51 class CMultilabelLabels : public CLabels
52 {
53 public:
56 
61  CMultilabelLabels(int32_t num_classes);
62 
68  CMultilabelLabels(int32_t num_labels, int32_t num_classes);
69 
72 
79  void ensure_valid(const char * context = NULL);
80 
85  virtual ELabelType get_label_type() const
86  {
87  return LT_SPARSE_MULTILABEL;
88  }
89 
91  virtual const char * get_name() const
92  {
93  return "MultilabelLabels";
94  }
95 
100  virtual int32_t get_num_labels() const;
101 
106  virtual int32_t get_num_classes() const;
107 
112  void set_labels(SGVector<int32_t> * labels);
113 
119 
125 
130  SGVector<int32_t> get_label(int32_t j);
131 
143  template <class S, class D>
144  static SGVector<D> to_dense(SGVector<S> * sparse, int32_t dense_len, D d_true, D d_false);
145 
151  void set_label(int32_t j, SGVector<int32_t> label);
152 
154  void set_class_labels(SGVector <int32_t> ** labels_list);
155 
157  void display() const;
158 
159 private:
160  void init(int32_t num_labels, int32_t num_classes);
161 
162 protected:
163 
164  int32_t m_num_labels;
165  int32_t m_num_classes;
167 };
168 
169 }
170 
171 #endif

SHOGUN Machine Learning Toolbox - Documentation