00001 /* 00002 * This program is free software; you can redistribute it and/or modify 00003 * it under the terms of the GNU General Public License as published by 00004 * the Free Software Foundation; either version 3 of the License, or 00005 * (at your option) any later version. 00006 * 00007 * Written (W) 1999-2009 Soeren Sonnenburg 00008 * Written (W) 1999-2008 Gunnar Raetsch 00009 * Subset support written (W) 2011 Heiko Strathmann 00010 * Copyright (C) 1999-2009 Fraunhofer Institute FIRST and Max-Planck-Society 00011 */ 00012 00013 #ifndef _LABELS__H__ 00014 #define _LABELS__H__ 00015 00016 #include <shogun/lib/common.h> 00017 #include <shogun/io/File.h> 00018 #include <shogun/base/SGObject.h> 00019 #include <shogun/features/Subset.h> 00020 00021 namespace shogun 00022 { 00023 class CFile; 00024 00035 class CLabels : public CSGObject 00036 { 00037 public: 00039 CLabels(); 00040 00045 CLabels(int32_t num_labels); 00046 00051 CLabels(SGVector<float64_t> src); 00052 00057 CLabels(CFile* loader); 00058 00060 virtual ~CLabels(); 00061 00068 virtual void load(CFile* loader); 00069 00076 virtual void save(CFile* writer); 00077 00086 bool set_label(int32_t idx, float64_t label); 00087 00096 bool set_int_label(int32_t idx, int32_t label); 00097 00105 float64_t get_label(int32_t idx); 00106 00114 int32_t get_int_label(int32_t idx); 00115 00122 bool is_two_class_labeling(); 00123 00130 int32_t get_num_classes(); 00131 00138 SGVector<float64_t> get_labels(); 00139 00146 void set_labels(SGVector<float64_t> v); 00147 00153 void set_to_one(); 00154 00162 SGVector<int32_t> get_int_labels(); 00163 00171 SGVector<float64_t> get_classes(); 00172 00180 void set_int_labels(SGVector<int32_t> labels); 00181 00186 int32_t get_num_labels(); 00187 00189 inline virtual const char* get_name() const { return "Labels"; } 00190 00195 virtual void set_subset(CSubset* subset); 00196 00198 virtual void remove_subset(); 00199 00205 index_t subset_idx_conversion(index_t idx) const; 00206 00207 private: 00208 void init(); 00209 00210 protected: 00212 SGVector<float64_t> labels; 00213 00215 int32_t m_num_classes; 00216 00217 private: 00218 /* subset class to enable subset support for this class */ 00219 CSubset* m_subset; 00220 }; 00221 } 00222 #endif