PLearn 0.1
|
00001 // -*- C++ -*- 00002 00003 // HyperLearner.h 00004 // Copyright (C) 2003-2004 ApSTAT Technologies Inc. 00005 // 00006 // Redistribution and use in source and binary forms, with or without 00007 // modification, are permitted provided that the following conditions are met: 00008 // 00009 // 1. Redistributions of source code must retain the above copyright 00010 // notice, this list of conditions and the following disclaimer. 00011 // 00012 // 2. Redistributions in binary form must reproduce the above copyright 00013 // notice, this list of conditions and the following disclaimer in the 00014 // documentation and/or other materials provided with the distribution. 00015 // 00016 // 3. The name of the authors may not be used to endorse or promote 00017 // products derived from this software without specific prior written 00018 // permission. 00019 // 00020 // THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR 00021 // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00022 // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN 00023 // NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00024 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 00025 // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00026 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 00027 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00028 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00029 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00030 // 00031 // This file is part of the PLearn library. For more information on the PLearn 00032 // library, go to the PLearn Web site at www.plearn.org 00033 00034 // Author: Pascal Vincent 00035 00036 /* ******************************************************* 00037 * $Id: HyperLearner.h 10220 2009-05-27 20:40:20Z tihocan $ 00038 ******************************************************* */ 00039 // Author: Pascal Vincent 00040 00043 #ifndef HyperLearner_INC 00044 #define HyperLearner_INC 00045 00046 #include "HyperCommand.h" 00047 #include <plearn_learners/generic/EmbeddedLearner.h> 00048 #include <plearn_learners/testers/PTester.h> 00049 00050 namespace PLearn { 00051 using namespace std; 00052 00053 // ###### HyperLearner ######################################################## 00054 00055 class HyperLearner: public EmbeddedLearner 00056 { 00057 typedef EmbeddedLearner inherited; 00058 00059 private: 00061 void build_(); 00062 00063 protected: 00064 00065 PStream::mode_t save_mode_; 00066 static void declareOptions(OptionList &ol); 00067 00068 public: 00069 00070 // Build options 00071 PP<PTester> tester; 00072 TVec<string> option_fields; 00073 TVec<string> dont_restart_upon_change; 00074 00075 TVec< PP<HyperCommand> > strategy; 00076 00077 string save_mode; 00078 bool provide_strategy_expdir; 00079 bool save_final_learner; 00080 bool save_strategy_learner; 00081 bool reloaded; 00082 // HyperLearner methods 00083 00085 bool finalize_learner; 00086 00087 HyperLearner(); 00088 00089 inline void setLearner(PP<PLearner> learner) 00090 { tester->learner = learner; learner_ = learner; } 00091 00092 // simply calls inherited::build() then build_() 00093 virtual void build(); 00094 00098 void setLearnerOptions(const TVec<string>& option_names, const TVec<string>& option_vals); 00099 00100 virtual void setTrainingSet(VMat training_set, bool call_forget=true); 00101 00104 virtual void train(); 00105 00106 virtual void forget(); 00107 virtual void finalize(); 00108 00110 TVec<string> getTrainCostNames() const; 00111 00112 PLEARN_DECLARE_OBJECT(HyperLearner); 00113 00114 void makeDeepCopyFromShallowCopy(CopiesMap& copies); 00115 00116 virtual void run(); 00117 00119 void auto_save(); 00120 00121 }; // class HyperLearner 00122 00123 DECLARE_OBJECT_PTR(HyperLearner); 00124 00125 00126 } // end of namespace PLearn 00127 00128 #endif // HyperLearner_INC 00129 00130 00131 /* 00132 Local Variables: 00133 mode:c++ 00134 c-basic-offset:4 00135 c-file-style:"stroustrup" 00136 c-file-offsets:((innamespace . 0)(inline-open . 0)) 00137 indent-tabs-mode:nil 00138 fill-column:79 00139 End: 00140 */ 00141 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=79 :