PLearn 0.1
Experimentation.h
Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 // Experimentation.h
00004 //
00005 // Copyright (C) 2006 Dan Popovici
00006 //
00007 // Redistribution and use in source and binary forms, with or without
00008 // modification, are permitted provided that the following conditions are met:
00009 //
00010 //  1. Redistributions of source code must retain the above copyright
00011 //     notice, this list of conditions and the following disclaimer.
00012 //
00013 //  2. Redistributions in binary form must reproduce the above copyright
00014 //     notice, this list of conditions and the following disclaimer in the
00015 //     documentation and/or other materials provided with the distribution.
00016 //
00017 //  3. The name of the authors may not be used to endorse or promote
00018 //     products derived from this software without specific prior written
00019 //     permission.
00020 //
00021 // THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
00022 // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00023 // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
00024 // NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00025 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
00026 // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00027 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00028 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00029 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00030 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00031 //
00032 // This file is part of the PLearn library. For more information on the PLearn
00033 // library, go to the PLearn Web site at www.plearn.org
00034 
00035 // Authors: Dan Popovici
00036 
00040 #ifndef Experimentation_INC
00041 #define Experimentation_INC
00042 
00043 #include <plearn_learners/generic/PLearner.h>
00044 #include <plearn_learners/testers/PTester.h>
00045 #include <plearn/vmat/FileVMatrix.h>
00046 #include <plearn/vmat/MemoryVMatrix.h>
00047 
00048 namespace PLearn {
00049 
00054 class Experimentation : public PLearner
00055 {
00056     typedef PLearner inherited;
00057 
00058 public:
00059 
00060     //#####  Public Build Options  ############################################
00061 
00064     
00066     int save_files;
00068     int experiment_without_missing_indicator;
00070     string target_field_name;
00072     TVec<string> missing_indicator_field_names;
00074     string experiment_name;
00076     int number_of_test_samples;
00078     int number_of_train_samples;
00080     VMat reference_train_set;
00082     VMat target_set;
00084     Vec deletion_thresholds;
00086     PPath experiment_directory;
00088     PP<PTester> experiment_template;
00089 
00090 public:
00091     //#####  Public Member Functions  #########################################
00092 
00094     // ### Make sure the implementation in the .cc
00095     // ### initializes all fields to reasonable default values.
00096     Experimentation();
00097     int outputsize() const;
00098     void train();
00099     void computeOutput(const Vec&, Vec&) const;
00100     void computeCostsFromOutputs(const Vec&, const Vec&, const Vec&, Vec&) const;
00101     TVec<string> getTestCostNames() const;
00102     TVec<string> getTrainCostNames() const;
00103 
00104 
00105     //#####  PLearn::Object Protocol  #########################################
00106 
00107     // Declares other standard object methods.
00108     // ### If your class is not instantiatable (it has pure virtual methods)
00109     // ### you should replace this by PLEARN_DECLARE_ABSTRACT_OBJECT_METHODS
00110     PLEARN_DECLARE_OBJECT(Experimentation);
00111 
00112     // Simply calls inherited::build() then build_()
00113     virtual void build();
00114 
00116     // (PLEASE IMPLEMENT IN .cc)
00117     virtual void makeDeepCopyFromShallowCopy(CopiesMap& copies);    
00118 
00119 protected:
00120     //#####  Protected Member Functions  ######################################
00121 
00123     static void declareOptions(OptionList& ol);
00124 
00125 private:
00126     //#####  Private Member Functions  ########################################
00127 
00129     void build_();
00130     void experimentSetUp();
00131     void createHeaderFile();
00132     void getHeaderRecord();
00133     void updateHeaderRecord(int var_col);
00134     void setSourceDataset();
00135     void reviewGlobalStats();
00136 
00137 private:
00138     //#####  Private Data Members  ############################################
00139 
00140     // The rest of the private stuff goes here
00141     
00142     int          main_row;
00143     int          main_col;
00144     int          main_length;
00145     int          main_width;
00146     Vec          main_input;
00147     TVec<string> main_names;
00148     PPath        main_metadata;
00149     int          main_fields_selected_col;
00150     TVec<string> main_fields_selected;
00151     
00152     int          fields_width;
00153     int          fields_col;
00154     
00155     int          target_row;
00156     int          target_col;
00157     int          target_length;
00158     int          target_width;
00159     Vec          target_input;
00160     TVec<string> target_names;
00161     
00162     int             header_width;
00163     Vec             header_record;
00164     TVec<string>    header_names;
00165     string          header_expdir;
00166     PPath           header_file_name;
00167     PP<FileVMatrix> header_file;
00168     
00169     int          to_deal_with_total;
00170     int          to_deal_with_next;
00171     real         deletion_threshold;
00172     string       deletion_threshold_str;
00173     
00174     int          test_length;
00175     int          test_width;
00176     Vec          test_record;
00177     VMat         test_file;
00178     
00179     int          train_valid_length;
00180     int          train_valid_width;
00181     Vec          train_valid_record;
00182     VMat         train_valid_file;
00183     
00184     VMat         source_set;
00185     TVec<string> source_names;
00186     PP<PTester>  experiment;
00187     
00188 /*
00189     PPath results_file_name;
00190     VMat results_file;
00191     int results_length;
00192     real results_nstages;
00193     real results_mse;
00194     real results_std_err;
00195     PPath test_output_file_name;
00196     VMat test_output_file;
00197     int test_output_length;
00198 */
00199     
00200 };
00201 
00202 // Declares a few other classes and functions related to this class
00203 DECLARE_OBJECT_PTR(Experimentation);
00204 
00205 } // end of namespace PLearn
00206 
00207 #endif
00208 
00209 
00210 /*
00211   Local Variables:
00212   mode:c++
00213   c-basic-offset:4
00214   c-file-style:"stroustrup"
00215   c-file-offsets:((innamespace . 0)(inline-open . 0))
00216   indent-tabs-mode:nil
00217   fill-column:79
00218   End:
00219 */
00220 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=79 :
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines