PLearn 0.1
|
00001 // -*- C++ -*- 00002 00003 // UCISpecification.cc 00004 // 00005 // Copyright (C) 2004 Olivier Delalleau 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 /* ******************************************************* 00036 * $Id: UCISpecification.cc 3994 2005-08-25 13:35:03Z chapados $ 00037 ******************************************************* */ 00038 00039 // Authors: Olivier Delalleau 00040 00044 #include "UCISpecification.h" 00045 00046 namespace PLearn { 00047 using namespace std; 00048 00049 UCISpecification::UCISpecification() 00050 : header_exists(0), 00051 header_fields(0), 00052 file_all(""), 00053 file_test(""), 00054 file_train(""), 00055 format("UCI"), 00056 inputsize(-1), 00057 targetsize(-1), 00058 weightsize(-1), 00059 target_is_first(0) 00060 { 00061 } 00062 00063 PLEARN_IMPLEMENT_OBJECT(UCISpecification, 00064 "Describes the specifications of a UCI database.", 00065 "This object specifies characteristics of a database from the UCI machine\n" 00066 "learning repository, such as the input size, target size, etc...\n" 00067 "It is intended to be used in a script put in the same directory as the\n" 00068 "database, in order to be loaded by the getDataSet() method.\n" 00069 "\n" 00070 "NB (Olivier): I am re-doing some stuff in there, it may be a bit messy...\n" 00071 ); 00072 00073 void UCISpecification::declareOptions(OptionList& ol) 00074 { 00075 // ### Declare all of this object's options here 00076 // ### For the "flags" of each option, you should typically specify 00077 // ### one of OptionBase::buildoption, OptionBase::learntoption or 00078 // ### OptionBase::tuningoption. Another possible flag to be combined with 00079 // ### is OptionBase::nosave 00080 00081 declareOption(ol, "header_exists", &UCISpecification::header_exists, OptionBase::buildoption, 00082 "Specifies if there is a header for the dataset"); 00083 00084 declareOption(ol, "header_fields", &UCISpecification::header_fields, OptionBase::buildoption, 00085 "The fields that are present in the header"); 00086 00087 declareOption(ol, "data_all", &UCISpecification::data_all, OptionBase::buildoption, 00088 "Filename for the whole dataset."); 00089 00090 declareOption(ol, "data_train", &UCISpecification::data_train, OptionBase::buildoption, 00091 "Filename for the train data."); 00092 00093 declareOption(ol, "data_test", &UCISpecification::data_test, OptionBase::buildoption, 00094 "Filename for the test data."); 00095 00096 declareOption(ol, "file_all", &UCISpecification::file_all, OptionBase::buildoption, 00097 "DEPRECATED: The filename for the whole dataset"); 00098 00099 declareOption(ol, "file_train", &UCISpecification::file_train, OptionBase::buildoption, 00100 "DEPRECATED: The filename for the train data."); 00101 00102 declareOption(ol, "file_test", &UCISpecification::file_test, OptionBase::buildoption, 00103 "DEPRECATED: The filename for the test data."); 00104 00105 declareOption(ol, "format", &UCISpecification::format, OptionBase::buildoption, 00106 "The format of the dataset file."); 00107 00108 declareOption(ol, "inputsize", &UCISpecification::inputsize, OptionBase::buildoption, 00109 "Input size of the data"); 00110 00111 declareOption(ol, "targetsize", &UCISpecification::targetsize, OptionBase::buildoption, 00112 "Target size of the data"); 00113 00114 declareOption(ol, "weightsize", &UCISpecification::weightsize, OptionBase::buildoption, 00115 "Weight size of the data"); 00116 00117 declareOption(ol, "target_is_first", &UCISpecification::target_is_first, OptionBase::buildoption, 00118 "Whether the target is the first column (otherwise it is assumed to be the last one)."); 00119 00120 // Now call the parent class' declareOptions 00121 inherited::declareOptions(ol); 00122 } 00123 00124 void UCISpecification::build_() 00125 { 00126 // ### This method should do the real building of the object, 00127 // ### according to set 'options', in *any* situation. 00128 // ### Typical situations include: 00129 // ### - Initial building of an object from a few user-specified options 00130 // ### - Building of a "reloaded" object: i.e. from the complete set of all serialised options. 00131 // ### - Updating or "re-building" of an object after a few "tuning" options have been modified. 00132 // ### You should assume that the parent class' build_() has already been called. 00133 } 00134 00135 // ### Nothing to add here, simply calls build_ 00136 void UCISpecification::build() 00137 { 00138 inherited::build(); 00139 build_(); 00140 } 00141 00142 void UCISpecification::makeDeepCopyFromShallowCopy(CopiesMap& copies) 00143 { 00144 inherited::makeDeepCopyFromShallowCopy(copies); 00145 00146 // ### Call deepCopyField on all "pointer-like" fields 00147 // ### that you wish to be deepCopied rather than 00148 // ### shallow-copied. 00149 // ### ex: 00150 // deepCopyField(trainvec, copies); 00151 00152 // ### Remove this line when you have fully implemented this method. 00153 PLERROR("UCISpecification::makeDeepCopyFromShallowCopy not fully (correctly) implemented yet!"); 00154 } 00155 00156 } // end of namespace PLearn 00157 00158 00159 /* 00160 Local Variables: 00161 mode:c++ 00162 c-basic-offset:4 00163 c-file-style:"stroustrup" 00164 c-file-offsets:((innamespace . 0)(inline-open . 0)) 00165 indent-tabs-mode:nil 00166 fill-column:79 00167 End: 00168 */ 00169 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=79 :