openModeller  Version 1.4.0
rf_alg.hh
Go to the documentation of this file.
00001 
00027 #ifndef _RF_ALGHH_
00028 #define _RF_ALGHH_
00029 
00030 #include <vector>
00031 
00032 #include <openmodeller/om.hh>
00033 #include <openmodeller/Random.hh>
00034 
00035 #include "librf/instance_set.h"
00036 #include "librf/tree.h"
00037 
00038 /*****************************************/
00039 /************* Random Forests ************/
00040 
00044 class RfAlgorithm : public AlgorithmImpl
00045 {
00046 public:
00047 
00048   RfAlgorithm();
00049 
00050   ~RfAlgorithm();
00051 
00052   int needNormalization();
00053   int initialize();
00054   int iterate();
00055   float getProgress() const;
00056   int done() const;
00057 
00058   Scalar getValue( const Sample& x ) const;
00059   int getConvergence( Scalar * const val ) const;
00060 
00061 protected:
00062 
00063   void _sampleToLine( Sample sample, stringstream& ss ) const;
00064 
00065   void _getConfiguration( ConfigurationPtr& ) const;
00066 
00067   void _setConfiguration( const ConstConfigurationPtr& );
00068 
00069   bool _done;
00070 
00071   int _num_trees;
00072 
00073   int _k;
00074 
00075   bool _initialized;
00076 
00077   Random _rand;
00078 
00079   librf::InstanceSet* _set; // only used for model creation
00080 
00081   vector<int> _class_weights;
00082 
00083   vector<librf::Tree*> _trees;
00084 };
00085 
00086 
00087 #endif
00088