PLearn 0.1
GenericNearestNeighbors.h
Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 // GenericNearestNeighbors.h
00004 //
00005 // Copyright (C) 2004 Nicolas Chapados
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: GenericNearestNeighbors.h 4337 2005-10-25 18:04:39Z chapados $ 
00037  ******************************************************* */
00038 
00039 // Authors: Nicolas Chapados
00040 
00041 
00042 #ifndef GenericNearestNeighbors_INC
00043 #define GenericNearestNeighbors_INC
00044 
00045 #include <plearn_learners/generic/PLearner.h>
00046 #include <plearn/ker/Kernel.h>
00047 
00048 namespace PLearn {
00049 
00090 class GenericNearestNeighbors;
00091 typedef PP< GenericNearestNeighbors > GenericNN;
00092 
00093 class GenericNearestNeighbors: public PLearner
00094 {
00095     typedef PLearner inherited;
00096 
00097 protected:
00099     mutable Vec currow;
00100   
00101 public:
00102     //#####  Public Build Options  ############################################
00103 
00106     int num_neighbors;
00107 
00110     bool copy_input;
00111 
00114     bool copy_target;
00115 
00119     bool copy_weight;
00120 
00123     bool copy_index;
00124   
00132     Ker distance_kernel;
00133 
00134 public:
00135     //#####  Object Methods  ##################################################
00136   
00138     GenericNearestNeighbors();
00139 
00140 
00142     virtual void build();
00143 
00145     virtual void makeDeepCopyFromShallowCopy(CopiesMap& copies);
00146 
00147     // Declares other standard object methods.
00148     // If your class is not instantiatable (it has pure virtual methods)
00149     // you should replace this by PLEARN_DECLARE_ABSTRACT_OBJECT.
00150     PLEARN_DECLARE_ABSTRACT_OBJECT(GenericNearestNeighbors);
00151 
00152 
00153 public:
00154     //#####  PLearner Methods  ################################################
00155 
00158     virtual int outputsize() const;
00159 
00160 private: 
00162     void build_();
00163 
00164 protected: 
00166     static void declareOptions(OptionList& ol);
00167 
00174     void constructOutputVector(const TVec<int>& indices, Vec& output,
00175                                const Mat& train_mat_override = Mat()) const;
00176 };
00177 
00178 // Declares a few other classes and functions related to this class.
00179 DECLARE_OBJECT_PTR(GenericNearestNeighbors);
00180 
00181 } // end of namespace PLearn
00182 
00183 #endif
00184 
00185 
00186 /*
00187   Local Variables:
00188   mode:c++
00189   c-basic-offset:4
00190   c-file-style:"stroustrup"
00191   c-file-offsets:((innamespace . 0)(inline-open . 0))
00192   indent-tabs-mode:nil
00193   fill-column:79
00194   End:
00195 */
00196 // 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