00001 /* 00002 * This file is part of MultiBoost, a multi-class 00003 * AdaBoost learner/classifier 00004 * 00005 * Copyright (C) 2005 Norman Casagrande 00006 * For informations write to nova77@gmail.com 00007 * 00008 * This library is free software; you can redistribute it and/or 00009 * modify it under the terms of the GNU Lesser General Public 00010 * License as published by the Free Software Foundation; either 00011 * version 2.1 of the License, or (at your option) any later version. 00012 * 00013 * This library is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 * Lesser General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU Lesser General Public 00019 * License along with this library; if not, write to the Free Software 00020 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00021 * 00022 */ 00023 00028 #ifndef __SINGLE_STUMP_LEARNER_H 00029 #define __SINGLE_STUMP_LEARNER_H 00030 00031 #include "WeakLearners/BaseLearner.h" 00032 #include "WeakLearners/StumpLearner.h" 00033 #include "Utils/Args.h" 00034 #include "IO/InputData.h" 00035 00036 #include <vector> 00037 #include <fstream> 00038 00039 using namespace std; 00040 00043 00044 namespace MultiBoost { 00045 00050 class SingleStumpLearner : public StumpLearner 00051 { 00052 public: 00053 00060 virtual BaseLearner* create() { return new SingleStumpLearner(); } 00061 00068 virtual void run(InputData* pData); 00069 00080 virtual void save(ofstream& outputStream, const int numTabs = 0); 00081 00089 virtual void load(nor_utils::StreamTokenizer& st); 00090 00091 private: 00092 00103 virtual char phi(double val, int classIdx); 00104 00116 virtual void findThreshold(InputData* pData, const int columnIdx, 00117 double& threshold, 00118 vector<sRates>& mu, vector<char>& v); 00119 00120 double _threshold; 00121 }; 00122 00123 } // end of namespace MultiBoost 00124 00125 #endif // __SINGLE_STUMP_LEARNER_H