00001 // -*- C++ -*- 00002 00003 // PLearn (A C++ Machine Learning Library) 00004 // Copyright (C) 1998 Pascal Vincent 00005 // Copyright (C) 1999-2002 Pascal Vincent, Yoshua Bengio and University of Montreal 00006 // Copyright (C) 2003 Olivier Delalleau 00007 // 00008 00009 // Redistribution and use in source and binary forms, with or without 00010 // modification, are permitted provided that the following conditions are met: 00011 // 00012 // 1. Redistributions of source code must retain the above copyright 00013 // notice, this list of conditions and the following disclaimer. 00014 // 00015 // 2. Redistributions in binary form must reproduce the above copyright 00016 // notice, this list of conditions and the following disclaimer in the 00017 // documentation and/or other materials provided with the distribution. 00018 // 00019 // 3. The name of the authors may not be used to endorse or promote 00020 // products derived from this software without specific prior written 00021 // permission. 00022 // 00023 // THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR 00024 // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00025 // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN 00026 // NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00027 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 00028 // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00029 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 00030 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00031 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00032 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00033 // 00034 // This file is part of the PLearn library. For more information on the PLearn 00035 // library, go to the PLearn Web site at www.plearn.org 00036 00037 /* ******************************************************* 00038 * $Id: LiftStatsCollector.h,v 1.9 2004/03/09 16:39:02 tihocan Exp $ 00039 * This file is part of the PLearn library. 00040 ******************************************************* */ 00041 00044 #ifndef LiftStatsCollector_INC 00045 #define LiftStatsCollector_INC 00046 00047 #include "VecStatsCollector.h" 00048 00049 namespace PLearn { 00050 using namespace std; 00051 00052 class LiftStatsCollector: public VecStatsCollector 00053 { 00054 00055 public: 00056 00057 typedef VecStatsCollector inherited; 00058 00059 protected: 00060 00061 // Protected options. 00062 00063 int count_fin; 00064 00065 // Fields below are not options. 00066 00069 Mat n_first_updates; 00070 00072 bool is_finalized; 00073 00075 int nstored; 00076 00078 int nsamples; 00079 00082 int npos; 00083 00085 int n_samples_to_keep; 00086 00088 int output_column_index; 00089 00090 public: 00091 00092 // ************************ 00093 // * public build options * 00094 // ************************ 00095 00096 real lift_fraction; 00097 int opposite_lift; 00098 string output_column; 00099 int sign_trick; 00100 int target_column; 00101 int verbosity; 00102 00103 // **************** 00104 // * Constructors * 00105 // **************** 00106 00107 // Default constructor, make sure the implementation in the .cc 00108 // initializes all fields to reasonable default values. 00109 LiftStatsCollector(); 00110 00111 00112 // ****************** 00113 // * Object methods * 00114 // ****************** 00115 00116 // A few overrides to properly save the accumulated information 00117 virtual void forget(); 00118 virtual void update(const Vec& x, real weight = 1.0); 00119 00122 virtual void finalize(); 00123 00126 virtual double getStat(const string& statspec); 00127 00128 protected: 00129 00131 real computeLift(); 00132 00134 real computeLiftMax(); 00135 00136 private: 00137 00139 void build_(); 00140 00141 protected: 00142 00144 static void declareOptions(OptionList& ol); 00145 00146 public: 00147 00148 // Declares other standard object methods 00149 // If your class is not instantiatable (it has pure virtual methods) 00150 // you should replace this by PLEARN_DECLARE_ABSTRACT_OBJECT_METHODS 00151 PLEARN_DECLARE_OBJECT(LiftStatsCollector); 00152 00153 // simply calls inherited::build() then build_(). 00154 virtual void build(); 00155 00157 virtual void makeDeepCopyFromShallowCopy(map<const void*, void*>& copies); 00158 00159 }; 00160 00161 // Declares a few other classes and functions related to this class 00162 DECLARE_OBJECT_PTR(LiftStatsCollector); 00163 00164 } // end of namespace PLearn 00165 00166 #endif