SHOGUN
v3.2.0
|
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 * Written (W) 2011 Heiko Strathmann 00010 * Copyright (C) 1999-2009 Fraunhofer Institute FIRST and Max-Planck-Society 00011 */ 00012 00013 #ifndef _DENSE_LABELS__H__ 00014 #define _DENSE_LABELS__H__ 00015 00016 #include <shogun/lib/common.h> 00017 #include <shogun/io/File.h> 00018 #include <shogun/labels/Labels.h> 00019 #include <shogun/features/SubsetStack.h> 00020 00021 namespace shogun 00022 { 00023 class CFile; 00024 00033 class CDenseLabels : public CLabels 00034 { 00035 public: 00037 CDenseLabels(); 00038 00043 CDenseLabels(int32_t num_labels); 00044 00049 CDenseLabels(CFile* loader); 00050 00052 virtual ~CDenseLabels(); 00053 00060 virtual void ensure_valid(const char* context=NULL); 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 00120 SGVector<float64_t> get_labels(); 00121 00128 SGVector<float64_t> get_labels_copy(); 00129 00136 void set_labels(SGVector<float64_t> v); 00137 00143 void set_to_one(); 00144 00150 void zero(); 00151 00159 void set_to_const(float64_t c); 00160 00167 SGVector<int32_t> get_int_labels(); 00168 00175 void set_int_labels(SGVector<int32_t> labels); 00176 00177 #if !defined(SWIGJAVA) && !defined(SWIGCSHARP) 00178 00184 void set_int_labels(SGVector<int64_t> labels); 00185 #endif 00186 00191 virtual int32_t get_num_labels() const; 00192 00197 virtual ELabelType get_label_type() const=0; 00198 00199 public: 00201 static const int32_t REJECTION_LABEL = -2; 00202 00203 private: 00204 void init(); 00205 00206 protected: 00208 SGVector<float64_t> m_labels; 00209 }; 00210 } 00211 #endif