PLearn 0.1
|
00001 // -*- C++ -*- 00002 00003 // CheckDond2FileSequence.cc 00004 // 00005 // Copyright (C) 2006 Dan Popovici, Pascal Lamblin 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 00039 #define PL_LOG_MODULE_NAME "CheckDond2FileSequence" 00040 00041 #include "CheckDond2FileSequence.h" 00042 #include <plearn/io/pl_log.h> 00043 00044 namespace PLearn { 00045 using namespace std; 00046 00047 PLEARN_IMPLEMENT_OBJECT( 00048 CheckDond2FileSequence, 00049 "Checks that the train set is in sequence", 00050 "" 00051 ); 00052 00054 // CheckDond2FileSequence // 00056 CheckDond2FileSequence::CheckDond2FileSequence() 00057 { 00058 } 00059 00061 // declareOptions // 00063 void CheckDond2FileSequence::declareOptions(OptionList& ol) 00064 { 00065 declareOption(ol, "key_col", &CheckDond2FileSequence::key_col, 00066 OptionBase::buildoption, 00067 "The column of the sequence key."); 00068 inherited::declareOptions(ol); 00069 } 00070 00072 // makeDeepCopyFromShallowCopy // 00074 void CheckDond2FileSequence::makeDeepCopyFromShallowCopy(CopiesMap& copies) 00075 { 00076 deepCopyField(key_col, copies); 00077 inherited::makeDeepCopyFromShallowCopy(copies); 00078 00079 } 00080 00082 // build // 00084 void CheckDond2FileSequence::build() 00085 { 00086 // ### Nothing to add here, simply calls build_(). 00087 inherited::build(); 00088 build_(); 00089 } 00090 00092 // build_ // 00094 void CheckDond2FileSequence::build_() 00095 { 00096 MODULE_LOG << "build_() called" << endl; 00097 if (train_set) 00098 { 00099 int row; 00100 real prev_key; 00101 Vec input(train_set->width()); 00102 train_set->getRow(0, input); 00103 prev_key = input[key_col]; 00104 for (row = 1; row < train_set->length(); row++) 00105 { 00106 train_set->getRow(row, input); 00107 if (input[key_col] < prev_key) 00108 { 00109 cout << "CheckDond2FileSequence: train set out of sequence" << endl; 00110 cout << "CheckDond2FileSequence: row: " << row << " previous key: " << prev_key << " current key: " << input[key_col] << endl; 00111 PLERROR("CheckDond2FileSequence: we are done here"); 00112 } 00113 if (input[key_col] == prev_key) 00114 { 00115 cout << "CheckDond2FileSequence: row: " << row << " previous key: " << prev_key << " current key: " << input[key_col] << endl; 00116 } 00117 prev_key = input[key_col]; 00118 if (row % 25000 == 0) cout << "CheckDond2FileSequence: " << row << " records processed." << endl; 00119 } 00120 cout << "CheckDond2FileSequence: " << row << " records processed." << endl; 00121 PLERROR("CheckDond2FileSequence: we are done here"); 00122 } 00123 } 00124 00125 int CheckDond2FileSequence::outputsize() const {return 0;} 00126 void CheckDond2FileSequence::train() {} 00127 void CheckDond2FileSequence::computeOutput(const Vec&, Vec&) const {} 00128 void CheckDond2FileSequence::computeCostsFromOutputs(const Vec&, const Vec&, const Vec&, Vec&) const {} 00129 TVec<string> CheckDond2FileSequence::getTestCostNames() const 00130 { 00131 TVec<string> result; 00132 result.append( "MSE" ); 00133 return result; 00134 } 00135 TVec<string> CheckDond2FileSequence::getTrainCostNames() const 00136 { 00137 TVec<string> result; 00138 result.append( "MSE" ); 00139 return result; 00140 } 00141 00142 } // end of namespace PLearn 00143 00144 00145 /* 00146 Local Variables: 00147 mode:c++ 00148 c-basic-offset:4 00149 c-file-style:"stroustrup" 00150 c-file-offsets:((innamespace . 0)(inline-open . 0)) 00151 indent-tabs-mode:nil 00152 fill-column:79 00153 End: 00154 */ 00155 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=79 :