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) 2013 Thoralf Klein 00008 * Written (W) 2012 Fernando José Iglesias García 00009 * Copyright (C) 2012 Fernando José Iglesias García 00010 */ 00011 00012 #ifndef _MULTICLASS_SO_LABELS__H__ 00013 #define _MULTICLASS_SO_LABELS__H__ 00014 00015 #include <shogun/labels/StructuredLabels.h> 00016 #include <shogun/lib/SGVector.h> 00017 #include <shogun/lib/StructuredData.h> 00018 #include <shogun/lib/StructuredDataTypes.h> 00019 00020 namespace shogun 00021 { 00022 00023 class CStructuredLabels; 00024 class CMulticlassSOLabels; 00025 00031 struct CRealNumber : public CStructuredData 00032 { 00034 STRUCTURED_DATA_TYPE(SDT_REAL); 00035 00040 CRealNumber(float64_t val) : CStructuredData(), value(val) { } 00041 00046 static CRealNumber* obtain_from_generic(CStructuredData* base_data) 00047 { 00048 if ( base_data->get_structured_data_type() == SDT_REAL ) 00049 return (CRealNumber*) base_data; 00050 else 00051 SG_SERROR("base_data must be of dynamic type CRealNumber\n") 00052 00053 return NULL; 00054 } 00055 00057 virtual const char* get_name() const { return "RealNumber"; } 00058 00060 float64_t value; 00061 }; 00062 00068 class CMulticlassSOLabels : public CStructuredLabels 00069 { 00070 public: 00072 CMulticlassSOLabels(); 00073 00078 CMulticlassSOLabels(int32_t num_labels); 00079 00084 CMulticlassSOLabels(SGVector< float64_t > const src); 00085 00087 virtual ~CMulticlassSOLabels(); 00088 00093 inline int32_t get_num_classes() { return m_num_classes; } 00094 00103 virtual void add_label(CStructuredData* label); 00104 00111 virtual CStructuredData* get_label(int32_t idx); 00112 00123 virtual bool set_label(int32_t idx, CStructuredData* label); 00124 00129 virtual int32_t get_num_labels() const; 00130 00132 virtual const char* get_name() const { return "MulticlassSOLabels"; } 00133 00134 private: 00135 void init(); 00136 00137 private: 00139 int32_t m_num_classes; 00140 00141 SGVector< float64_t > m_labels_vector; 00142 int32_t m_num_labels_set; 00143 00144 }; /* CMulticlassSOLabels */ 00145 00146 } /* namespace shogun */ 00147 00148 #endif /* _MULTICLASS_SO_LABELS__H__ */