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) 2012 Philippe Tillet 00008 */ 00009 00010 #ifndef _NEAREST_CENTROID_H__ 00011 #define _NEAREST_CENTROID_H__ 00012 00013 #include <stdio.h> 00014 #include <shogun/lib/common.h> 00015 #include <shogun/io/SGIO.h> 00016 #include <shogun/features/Features.h> 00017 #include <shogun/features/DenseFeatures.h> 00018 #include <shogun/distance/Distance.h> 00019 #include <shogun/machine/DistanceMachine.h> 00020 00021 namespace shogun 00022 { 00023 00024 class CDistanceMachine; 00025 00032 class CNearestCentroid : public CDistanceMachine{ 00033 00034 public: 00035 00037 MACHINE_PROBLEM_TYPE(PT_MULTICLASS); 00038 00042 CNearestCentroid(); 00043 00049 CNearestCentroid(CDistance* distance, CLabels* trainlab); 00050 00053 virtual ~CNearestCentroid(); 00054 00059 void set_shrinking(float64_t shrinking) { 00060 m_shrinking = shrinking ; 00061 } 00062 00067 float64_t get_shrinking() const{ 00068 return m_shrinking; 00069 } 00070 00075 CDenseFeatures<float64_t>* get_centroids() const{ 00076 return m_centroids; 00077 } 00078 00083 virtual const char* get_name() const { return "NearestCentroid"; } 00084 00085 protected: 00094 virtual bool train_machine(CFeatures* data=NULL); 00095 00101 private: 00102 void init(); 00103 00104 protected: 00106 int32_t m_num_classes; 00107 00109 float64_t m_shrinking; 00110 00112 CDenseFeatures<float64_t>* m_centroids; 00113 00115 bool m_is_trained; 00116 }; 00117 00118 } 00119 00120 #endif