NearestCentroid.h

Go to the documentation of this file.
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/lib/CoverTree.h>
00020 #include <shogun/machine/DistanceMachine.h>
00021 
00022 namespace shogun
00023 {
00024 
00025 class CDistanceMachine;
00026 
00033 class CNearestCentroid : public CDistanceMachine{
00034     
00035 public:
00036 
00038     MACHINE_PROBLEM_TYPE(PT_MULTICLASS);
00039 
00043     CNearestCentroid();
00044     
00050     CNearestCentroid(CDistance* distance, CLabels* trainlab);
00051     
00054     virtual ~CNearestCentroid();
00055     
00060     void set_shrinking(float64_t shrinking) {
00061         m_shrinking = shrinking ;
00062     }
00063     
00068     float64_t get_shrinking() const{
00069         return m_shrinking;
00070     }
00071 
00076     CDenseFeatures<float64_t>* get_centroids() const{
00077         return m_centroids;
00078     }
00079     
00080 protected:
00089     virtual bool train_machine(CFeatures* data=NULL);
00090     
00096 private:
00097     void init();
00098     
00099 protected:
00101     int32_t m_num_classes;
00102     
00104     float64_t m_shrinking;
00105     
00107     CDenseFeatures<float64_t>* m_centroids;
00108     
00110     bool m_is_trained;
00111 };
00112 
00113 }
00114 
00115 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

SHOGUN Machine Learning Toolbox - Documentation