/** * @file VCPreRandomForest.h * @brief Combination of a classifier with a pre-clustering using a random forest * @author Erik Rodner * @date 06/17/2010 */ #ifndef VCPRERANDOMFORESTINCLUDE #define VCPRERANDOMFORESTINCLUDE #include "core/vector/VectorT.h" #include "core/vector/MatrixT.h" #include "core/image/ImageT.h" #include "core/imagedisplay/ImageDisplay.h" #include #include "vislearning/cbaselib/LabeledSet.h" #include "vislearning/classifier/classifierbase/VecClassifier.h" #include "vislearning/classifier/fpclassifier/randomforest/FPCRandomForests.h" #define ROADWORKS fthrow(Exception,"VCPreRandomForest: not yet implemented."); namespace OBJREC { /** Combination of a classifier with a pre-clustering using a random forest */ class VCPreRandomForest : public VecClassifier { protected: /** the classifier prototype used to classify all examples in a leaf */ VecClassifier *leafClassifierPrototype; /** classifiers of each leaf */ std::map leafClassifiers; /** the random forest used to pre-cluster the features */ FPCRandomForests *randomforest; /** feature pool needed for the random forest */ FeaturePool fp; /** maximum number of Examples in a leaf*/ int mEx; public: /** simple constructor */ VCPreRandomForest( const NICE::Config *conf, const std::string & section, VecClassifier *leafClassifier ); /** simple destructor */ virtual ~VCPreRandomForest(); /** classify using simple vector */ ClassificationResult classify ( const NICE::Vector & x ) const; /** teach the classifier using a training set */ void teach ( const LabeledSetVector & teachSet ); void finishTeaching() { /* nothing to do */ }; void clear(); void store ( std::ostream & os, int format = 0 ) const { #if 0 // not working yet, no store functino for DecisionNode os << leafClassifiers.size() << endl; std::map::iterator iter; for( iter = leafClassifiers.begin(); iter != leafClassifiers.end(); ++iter ) { iter->first->store(os,format); iter->second->store(os,format); } randomforest->store(os,format); leafClassifierPrototype->store(os,format); #endif }; void restore ( std::istream & is, int format = 0 ) { #if 0 // not working yet, no restore function for DecisionNode, no idea how generic classifier restore int size; is >> size; for(int i = 0; i < size; i++) { DecisionNode *dn = new DecisionNode(); dn->restore(is); VecClassifier * } #endif }; }; } // namespace #undef ROADWORKS #endif