PLearn 0.1
LiftStatsCollector.h
Go to the documentation of this file.
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 3994 2005-08-25 13:35:03Z chapados $
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 private:
00056 
00057     typedef VecStatsCollector inherited;
00058 
00059 protected:
00060 
00061     // Protected options.
00062   
00063     int count_fin;
00064     Vec roc_values;
00065 
00066     // Fields below are not options.
00067 
00070     Mat n_first_updates;
00071 
00073     bool is_finalized;
00074 
00076     int nstored;
00077 
00079     int nsamples;
00080 
00083     int npos;
00084 
00086     int n_samples_to_keep;
00087 
00089     int output_column_index;
00090 
00091 public:
00092 
00093     // ************************
00094     // * public build options *
00095     // ************************
00096 
00097     string lift_file;
00098     real lift_fraction;
00099     bool opposite_lift;
00100     string output_column;
00101     string roc_file;
00102     Vec roc_fractions;
00103     int sign_trick;
00104     int target_column;
00105     int verbosity;
00106 
00107     // ****************
00108     // * Constructors *
00109     // ****************
00110 
00111     // Default constructor, make sure the implementation in the .cc
00112     // initializes all fields to reasonable default values.
00113     LiftStatsCollector();
00114 
00115 
00116     // ******************
00117     // * Object methods *
00118     // ******************
00119 
00120     // A few overrides to properly save the accumulated information
00121     virtual void forget();
00122     virtual void update(const Vec& x, real weight = 1.0);
00123 
00126     virtual void finalize();
00127 
00130     virtual double getStat(const string& statspec);
00131 
00133     virtual void remove_observation(const Vec& x, real weight = 1.0);
00134 
00135 protected:
00136 
00138     real computeAUC();
00139 
00141     real computeLift();
00142   
00144     real computeLiftMax();
00145 
00146 private: 
00147 
00149     void build_();
00150 
00151 protected: 
00152 
00154     static void declareOptions(OptionList& ol);
00155 
00156 public:
00157 
00158     // Declares other standard object methods
00159     PLEARN_DECLARE_OBJECT(LiftStatsCollector);
00160 
00161     // simply calls inherited::build() then build_().
00162     virtual void build();
00163 
00165     virtual void makeDeepCopyFromShallowCopy(CopiesMap& copies);
00166 
00167 };
00168 
00169 // Declares a few other classes and functions related to this class
00170 DECLARE_OBJECT_PTR(LiftStatsCollector);
00171   
00172 } // end of namespace PLearn
00173 
00174 #endif
00175 
00176 
00177 /*
00178   Local Variables:
00179   mode:c++
00180   c-basic-offset:4
00181   c-file-style:"stroustrup"
00182   c-file-offsets:((innamespace . 0)(inline-open . 0))
00183   indent-tabs-mode:nil
00184   fill-column:79
00185   End:
00186 */
00187 // 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