PLearn 0.1
MergeDond2Files.h
Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 // MergeDond2Files.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 MergeDond2Files_INC
00041 #define MergeDond2Files_INC
00042 
00043 #include <plearn_learners/generic/PLearner.h>
00044 #include <plearn/vmat/FileVMatrix.h>
00045 
00046 namespace PLearn {
00047 
00052 class MergeDond2Files : public PLearner
00053 {
00054     typedef PLearner inherited;
00055 
00056 public:
00057 
00058     //#####  Public Build Options  ############################################
00059 
00062     
00065     VMat external_dataset;
00066 
00069     TVec< pair<string, string> >  missing_instructions;
00070     
00073     TVec< pair<string, string> >  merge_instructions;
00074     
00076     string merge_path;
00077     
00079     int sec_key;
00080     
00082     int main_key;
00083     
00085     int train_ind;
00086     
00088     int test_ind;
00089     
00091     VMat train_file;
00092     
00094     VMat test_file;
00095     
00097     VMat unknown_file;
00098 
00099 public:
00100     //#####  Public Member Functions  #########################################
00101 
00103     // ### Make sure the implementation in the .cc
00104     // ### initializes all fields to reasonable default values.
00105     MergeDond2Files();
00106     int outputsize() const;
00107     void train();
00108     void computeOutput(const Vec&, Vec&) const;
00109     void computeCostsFromOutputs(const Vec&, const Vec&, const Vec&, Vec&) const;
00110     TVec<string> getTestCostNames() const;
00111     TVec<string> getTrainCostNames() const;
00112 
00113 
00114     //#####  PLearn::Object Protocol  #########################################
00115 
00116     // Declares other standard object methods.
00117     // ### If your class is not instantiatable (it has pure virtual methods)
00118     // ### you should replace this by PLEARN_DECLARE_ABSTRACT_OBJECT_METHODS
00119     PLEARN_DECLARE_OBJECT(MergeDond2Files);
00120 
00121     // Simply calls inherited::build() then build_()
00122     virtual void build();
00123 
00125     // (PLEASE IMPLEMENT IN .cc)
00126     virtual void makeDeepCopyFromShallowCopy(CopiesMap& copies);    
00127 
00128 protected:
00129     //#####  Protected Member Functions  ######################################
00130 
00132     static void declareOptions(OptionList& ol);
00133 
00134 private:
00135     //#####  Private Member Functions  ########################################
00136 
00138     void build_();
00139     void mergeFiles();
00140     void accumulateVec();
00141     void combineAndPut();
00142 
00143 private:
00144     //#####  Private Data Members  ############################################
00145 
00146     // The rest of the private stuff goes here
00147     // secondary dataset variables
00148     int sec_length;
00149     int sec_width;
00150     int sec_row;
00151     Vec sec_input;
00152     TVec<string> sec_names;
00153     TVec<string> sec_ins;
00154     int extension_width;
00155     int ext_col;
00156     TVec<int> extension_pos;
00157     TVec<string> extension_names;
00158     Mat sec_values;
00159     Mat sec_value_cnt;
00160     TVec<int> sec_value_ind;
00161     bool sec_value_found;
00162     real sec_value_count_max;
00163     
00164     // primary dataset variables
00165     int main_length;
00166     int main_width;
00167     int main_row;
00168     Vec main_input;
00169     TVec<string> main_names;
00170     TVec<string> main_ins;
00171     int primary_width;
00172     TVec<string> primary_names;
00173     
00174     // merge dataset variables
00175     int train_length;
00176     int test_length;
00177     int unknown_length;
00178     int merge_width;
00179     int train_row;
00180     int test_row;
00181     int unknown_row;
00182     int merge_col;
00183     Vec merge_output;
00184     TVec<string> merge_names;
00185 };
00186 
00187 // Declares a few other classes and functions related to this class
00188 DECLARE_OBJECT_PTR(MergeDond2Files);
00189 
00190 } // end of namespace PLearn
00191 
00192 #endif
00193 
00194 
00195 /*
00196   Local Variables:
00197   mode:c++
00198   c-basic-offset:4
00199   c-file-style:"stroustrup"
00200   c-file-offsets:((innamespace . 0)(inline-open . 0))
00201   indent-tabs-mode:nil
00202   fill-column:79
00203   End:
00204 */
00205 // 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