latest version v1.9 - last update 10 Apr 2010 |
00001 /* 00002 * Copyright (C) 2002, 2003, 2004, 2005, 2006 00003 * Lehrstuhl fuer Technische Informatik, RWTH-Aachen, Germany 00004 * 00005 * This file is part of the LTI-Computer Vision Library (LTI-Lib) 00006 * 00007 * The LTI-Lib is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU Lesser General Public License (LGPL) 00009 * as published by the Free Software Foundation; either version 2.1 of 00010 * the License, or (at your option) any later version. 00011 * 00012 * The LTI-Lib is distributed in the hope that it will be 00013 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty 00014 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU Lesser General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU Lesser General Public 00018 * License along with the LTI-Lib; see the file LICENSE. If 00019 * not, write to the Free Software Foundation, Inc., 59 Temple Place - 00020 * Suite 330, Boston, MA 02111-1307, USA. 00021 */ 00022 00023 00024 /*-------------------------------------------------------------------- 00025 * project ....: LTI-Lib: Image Processing and Computer Vision Library 00026 * file .......: ltiPlusLTakeAwayR.h 00027 * authors ....: Jens Paustenbach 00028 * organization: LTI, RWTH Aachen 00029 * creation ...: 8.7.2002 00030 * revisions ..: $Id: ltiPlusLTakeAwayR.h,v 1.7 2006/02/07 18:21:46 ltilib Exp $ 00031 */ 00032 00033 #ifndef _LTI_PLUS_L_TAKE_AWAY_R_H_ 00034 #define _LTI_PLUS_L_TAKE_AWAY_R_H_ 00035 00036 #include "ltiFeatureSelector.h" 00037 00038 #include "ltiVector.h" 00039 #include "ltiMatrix.h" 00040 #include "ltiCostFunction.h" 00041 00042 namespace lti { 00043 /** 00044 * This class implements the plus l - take away r algorithm descripted in: 00045 * P. Pudil, F.J. Ferri, J. Novovicova, J. Kittler. "Floating Search Methods 00046 * for Feature Selection with nonmonotonic criterion functions" 00047 * Proceddings of the IEEE Intl. Conf. on Pattern Recognition, 00048 * 279-283, 1994; 00049 * In each iteration it adds the l best features and from the source data 00050 * to the destination data. Then the r least significant features are 00051 * deleted from this data set. This is done until the predetermined 00052 * number of features is reached 00053 * As criterion function cross validation is used. 00054 */ 00055 class plusLTakeAwayR : public featureSelector { 00056 public: 00057 /** 00058 * the parameters for the class plusLTakeAwayR 00059 */ 00060 class parameters : public featureSelector::parameters { 00061 public: 00062 /** 00063 * default constructor 00064 */ 00065 parameters(); 00066 00067 /** 00068 * copy constructor 00069 * @param other the parameters object to be copied 00070 */ 00071 parameters(const parameters& other); 00072 00073 /** 00074 * destructor 00075 */ 00076 ~parameters(); 00077 00078 /** 00079 * returns name of this type 00080 */ 00081 const char* getTypeName() const; 00082 00083 /** 00084 * copy the contents of a parameters object 00085 * @param other the parameters object to be copied 00086 * @return a reference to this parameters object 00087 */ 00088 parameters& copy(const parameters& other); 00089 00090 /** 00091 * copy the contents of a parameters object 00092 * @param other the parameters object to be copied 00093 * @return a reference to this parameters object 00094 */ 00095 parameters& operator=(const parameters& other); 00096 00097 00098 /** 00099 * returns a pointer to a clone of the parameters 00100 */ 00101 virtual functor::parameters* clone() const; 00102 00103 /** 00104 * write the parameters in the given ioHandler 00105 * @param handler the ioHandler to be used 00106 * @param complete if true (the default) the enclosing begin/end will 00107 * be also written, otherwise only the data block will be written. 00108 * @return true if write was successful 00109 */ 00110 virtual bool write(ioHandler& handler,const bool complete=true) const; 00111 00112 /** 00113 * read the parameters from the given ioHandler 00114 * @param handler the ioHandler to be used 00115 * @param complete if true (the default) the enclosing begin/end will 00116 * be also written, otherwise only the data block will be written. 00117 * @return true if write was successful 00118 */ 00119 virtual bool read(ioHandler& handler,const bool complete=true); 00120 00121 # ifdef _LTI_MSC_6 00122 /** 00123 * this function is required by MSVC only, as a workaround for a 00124 * very awful bug, which exists since MSVC V.4.0, and still by 00125 * V.6.0 with all bugfixes (so called "service packs") remains 00126 * there... This method is also public due to another bug, so please 00127 * NEVER EVER call this method directly: use read() instead 00128 */ 00129 bool readMS(ioHandler& handler,const bool complete=true); 00130 00131 /** 00132 * this function is required by MSVC only, as a workaround for a 00133 * very awful bug, which exists since MSVC V.4.0, and still by 00134 * V.6.0 with all bugfixes (so called "service packs") remains 00135 * there... This method is also public due to another bug, so please 00136 * NEVER EVER call this method directly: use write() instead 00137 */ 00138 bool writeMS(ioHandler& handler,const bool complete=true) const; 00139 # endif 00140 00141 // ------------------------------------------------ 00142 // the parameters 00143 // ------------------------------------------------ 00144 00145 /** 00146 * the number of features that are removed in each iteration 00147 */ 00148 int r; 00149 00150 /** 00151 * the number of features that are included in each iteration 00152 */ 00153 int l; 00154 00155 /** 00156 * A pointer to the cost function that is used to evaluate the 00157 * feature subset. 00158 */ 00159 costFunction* usedCostFunction; 00160 00161 // /** 00162 // * parameter object that is used if cross validation is used as 00163 // * cost function. In all other cases this parameter is not used. 00164 // */ 00165 // crossValidator::parameters cVParameter; 00166 00167 // /** 00168 // * the different choices for the costFunction 00169 // */ 00170 // enum eCostFunctions { 00171 // BhattacharyyaDistance, 00172 // MahalanobisDistance, 00173 // CrossValidation 00174 // }; 00175 00176 // /** 00177 // * The cost function that is used to decide if a feature is better than 00178 // * an other feature. 00179 // */ 00180 // eCostFunctions costFunction; 00181 00182 }; 00183 00184 /** 00185 * default constructor 00186 */ 00187 plusLTakeAwayR(); 00188 00189 /** 00190 * copy constructor 00191 * @param other the object to be copied 00192 */ 00193 plusLTakeAwayR(const plusLTakeAwayR& other); 00194 00195 /** 00196 * destructor 00197 */ 00198 virtual ~plusLTakeAwayR(); 00199 00200 /** 00201 * returns the name of this type ("plusLTakeAwayR") 00202 */ 00203 virtual const char* getTypeName() const; 00204 00205 /** 00206 * extracts the k, that is a parameter, best features of src 00207 * and copies them to dest 00208 * @param src dmatrix with the source data. 00209 * @param srcIds ivector with the ids corresponding to src 00210 * @param dest dmatrix where the result will be left. 00211 * @return true if apply successful or false otherwise. 00212 */ 00213 bool apply(const dmatrix& src,const ivector& srcIds, dmatrix& dest) const; 00214 00215 /** 00216 * copy data of "other" functor. 00217 * @param other the functor to be copied 00218 * @return a reference to this functor object 00219 */ 00220 plusLTakeAwayR& copy(const plusLTakeAwayR& other); 00221 00222 /** 00223 * alias for copy member 00224 * @param other the functor to be copied 00225 * @return a reference to this functor object 00226 */ 00227 plusLTakeAwayR& operator=(const plusLTakeAwayR& other); 00228 00229 /** 00230 * returns a pointer to a clone of this functor. 00231 */ 00232 virtual functor* clone() const; 00233 00234 /** 00235 * returns used parameters 00236 */ 00237 const parameters& getParameters() const; 00238 00239 }; 00240 } 00241 00242 #endif