PLearn 0.1
AnalyzeFieldStats.h
Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 // AnalyzeFieldStats.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 AnalyzeFieldStats_INC
00041 #define AnalyzeFieldStats_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 AnalyzeFieldStats : public PLearner
00055 {
00056     typedef PLearner inherited;
00057 
00058 public:
00059 
00060     //#####  Public Build Options  ############################################
00061 
00064     
00066     int min_number_of_samples;
00068     int max_number_of_samples;
00070     VMat targeted_set;
00072     PP<PTester> cond_mean_template;
00074     TVec<string> fields;
00075 
00076 public:
00077     //#####  Public Member Functions  #########################################
00078 
00080     // ### Make sure the implementation in the .cc
00081     // ### initializes all fields to reasonable default values.
00082     AnalyzeFieldStats();
00083     int outputsize() const;
00084     void train();
00085     void computeOutput(const Vec&, Vec&) const;
00086     void computeCostsFromOutputs(const Vec&, const Vec&, const Vec&, Vec&) const;
00087     TVec<string> getTestCostNames() const;
00088     TVec<string> getTrainCostNames() const;
00089 
00090 
00091     //#####  PLearn::Object Protocol  #########################################
00092 
00093     // Declares other standard object methods.
00094     // ### If your class is not instantiatable (it has pure virtual methods)
00095     // ### you should replace this by PLEARN_DECLARE_ABSTRACT_OBJECT_METHODS
00096     PLEARN_DECLARE_OBJECT(AnalyzeFieldStats);
00097 
00098     // Simply calls inherited::build() then build_()
00099     virtual void build();
00100 
00102     // (PLEASE IMPLEMENT IN .cc)
00103     virtual void makeDeepCopyFromShallowCopy(CopiesMap& copies);    
00104 
00105 protected:
00106     //#####  Protected Member Functions  ######################################
00107 
00109     static void declareOptions(OptionList& ol);
00110 
00111 private:
00112     //#####  Private Member Functions  ########################################
00113 
00115     void build_();
00116     void analyzeVariableStats();
00117     void createHeaderFile();
00118     void getHeaderRecord();
00119     void updateHeaderRecord(int var_col);
00120     void reviewGlobalStats();
00121 
00122 private:
00123     //#####  Private Data Members  ############################################
00124 
00125     // The rest of the private stuff goes here
00126     
00127     int main_width;
00128     TVec<string> main_names;
00129     StatsCollector  main_stats;
00130     PPath main_metadata;
00131     TVec<int> main_ins;
00132     real main_total;
00133     real main_missing;
00134     real main_present;
00135     int targeted_length;
00136     int targeted_width;
00137     Vec targeted_input;
00138     TVec<string> targeted_names;
00139     StatsCollector  targeted_stats;
00140     PPath targeted_metadata;
00141     real targeted_missing;
00142     PPath header_file_name;
00143     VMat header_file;
00144     Vec header_record;
00145     int fields_col;
00146     int fields_width;
00147     TVec<int> fields_selected;
00148     int to_deal_with_total;
00149     int to_deal_with_next;
00150     real to_deal_with_value;
00151     string to_deal_with_name;
00152     int ind_next;
00153     int output_length;
00154     int output_width;
00155     int output_col;
00156     string output_path;
00157     TVec<string> output_names;
00158     Vec output_vec;
00159     TVec<int> output_variable_src;
00160     VMat output_file;
00161     int train_test_length;
00162     string train_test_path;
00163     TVec<int> train_test_variable_src;
00164     VMat train_test_file;
00165     PPath results_file_name;
00166     VMat results_file;
00167     int results_length;
00168     real results_nstages;
00169     real results_mse;
00170     real results_std_err;
00171     PPath test_output_file_name;
00172     VMat test_output_file;
00173     int test_output_length;
00174     
00175 };
00176 
00177 // Declares a few other classes and functions related to this class
00178 DECLARE_OBJECT_PTR(AnalyzeFieldStats);
00179 
00180 } // end of namespace PLearn
00181 
00182 #endif
00183 
00184 
00185 /*
00186   Local Variables:
00187   mode:c++
00188   c-basic-offset:4
00189   c-file-style:"stroustrup"
00190   c-file-offsets:((innamespace . 0)(inline-open . 0))
00191   indent-tabs-mode:nil
00192   fill-column:79
00193   End:
00194 */
00195 // 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