Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members

PCA.h

Go to the documentation of this file.
00001 // -*- C++ -*- 00002 00003 // PCA.h 00004 // 00005 // Copyright (C) 2003 Pascal Vincent 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: PCA.h,v 1.8 2004/07/21 16:30:59 chrish42 Exp $ 00037 ******************************************************* */ 00038 00040 #ifndef PCA_INC 00041 #define PCA_INC 00042 00043 #include <plearn_learners/generic/PLearner.h> 00044 00045 namespace PLearn { 00046 using namespace std; 00047 00048 class PCA: public PLearner 00049 { 00050 00051 private: 00052 00053 typedef PLearner inherited; 00054 00055 public: 00056 00057 // ************************ 00058 // * public build options * 00059 // ************************ 00060 00061 string algo; 00062 int ncomponents; 00063 real sigmasq; 00064 bool normalize; 00065 00066 // Saved options 00067 Vec mu; 00068 Vec eigenvals; 00069 Mat eigenvecs; 00070 00071 // **************** 00072 // * Constructors * 00073 // **************** 00074 00076 PCA(); 00077 00078 // ****************** 00079 // * PLearner methods * 00080 // ****************** 00081 00082 private: 00083 00085 void build_(); 00086 00087 protected: 00088 00090 static void declareOptions(OptionList& ol); 00091 00092 public: 00093 00094 // ************************ 00095 // **** Object methods **** 00096 // ************************ 00097 00099 virtual void build(); 00100 00102 virtual void makeDeepCopyFromShallowCopy(map<const void*, void*>& copies); 00103 00104 // Declares other standard object methods 00105 // If your class is not instantiatable (it has pure virtual methods) 00106 // you should replace this by PLEARN_DECLARE_ABSTRACT_OBJECT_METHODS 00107 PLEARN_DECLARE_OBJECT(PCA); 00108 00109 00110 // ************************** 00111 // **** PLearner methods **** 00112 // ************************** 00113 00116 virtual int outputsize() const; 00117 00120 virtual void forget(); 00121 00122 00125 virtual void train(); 00126 00127 00129 virtual void computeOutput(const Vec& input, Vec& output) const; 00130 00132 void reconstruct(const Vec& output, Vec& input) const; 00133 00136 virtual void computeCostsFromOutputs(const Vec& input, const Vec& output, 00137 const Vec& target, Vec& costs) const; 00138 00139 00141 virtual TVec<string> getTestCostNames() const; 00142 00143 00145 virtual TVec<string> getTrainCostNames() const; 00146 00147 00148 // *** SUBCLASS WRITING: *** 00149 // While in general not necessary, in case of particular needs 00150 // (efficiency concerns for ex) you may also want to overload 00151 // some of the following methods: 00152 // virtual void computeOutputAndCosts(const Vec& input, const Vec& target, Vec& output, Vec& costs) const; 00153 // virtual void computeCostsOnly(const Vec& input, const Vec& target, Vec& costs) const; 00154 // virtual void test(VMat testset, PP<VecStatsCollector> test_stats, VMat testoutputs=0, VMat testcosts=0) const; 00155 // virtual int nTestCosts() const; 00156 // virtual int nTrainCosts() const; 00157 }; 00158 00159 // Declares a few other classes and functions related to this class 00160 DECLARE_OBJECT_PTR(PCA); 00161 00162 } // end of namespace PLearn 00163 00164 #endif

Generated on Tue Aug 17 16:00:55 2004 for PLearn by doxygen 1.3.7