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

LLE.cc

Go to the documentation of this file.
00001 // -*- C++ -*- 00002 00003 // LLE.cc 00004 // 00005 // Copyright (C) 2004 Olivier Delalleau 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: LLE.cc,v 1.4 2004/07/20 22:00:07 tihocan Exp $ 00037 ******************************************************* */ 00038 00039 // Authors: Olivier Delalleau 00040 00044 #include "LLE.h" 00045 00046 namespace PLearn { 00047 using namespace std; 00048 00050 // LLE // 00052 LLE::LLE() 00053 : classical_induction(true), 00054 knn(5), 00055 reconstruct_coeff(-1), 00056 regularizer(1e-6) 00057 { 00058 lle_kernel = new LLEKernel(); 00059 this->normalize = 1; // In LLE, we normalize. 00060 this->ignore_n_first = 1; // In LLE, we ignore the first eigenvector. 00061 } 00062 00063 PLEARN_IMPLEMENT_OBJECT(LLE, 00064 "Performs Locally Linear Embedding.", 00065 "" 00066 ); 00067 00069 // declareOptions // 00071 void LLE::declareOptions(OptionList& ol) 00072 { 00073 // Build options. 00074 00075 declareOption(ol, "knn", &LLE::knn, OptionBase::buildoption, 00076 "The number of nearest neighbors considered."); 00077 00078 declareOption(ol, "classical_induction", &LLE::classical_induction, OptionBase::buildoption, 00079 "If set to 1, then the out-of-sample extension of LLE will be the classical\n" 00080 "one, corresponding to an infinite 'reconstruct_coeff' (whose value is ignored)."); 00081 00082 declareOption(ol, "reconstruct_coeff", &LLE::reconstruct_coeff, OptionBase::buildoption, 00083 "The weight of K' in the weighted sum of K' and K'' (see LLEKernel)."); 00084 00085 declareOption(ol, "regularizer", &LLE::regularizer, OptionBase::buildoption, 00086 "The regularization factor used to make the linear systems stable."); 00087 00088 // Learnt options. 00089 00090 declareOption(ol, "lle_kernel", &LLE::lle_kernel, OptionBase::learntoption, 00091 "The kernel used in LLE."); 00092 00093 // Now call the parent class' declareOptions. 00094 inherited::declareOptions(ol); 00095 00096 // Hide unused options from KernelProjection. 00097 redeclareOption(ol, "kernel", &LLE::kernel, OptionBase::nosave, 00098 "Will be set at build time."); 00099 00100 redeclareOption(ol, "normalize", &LLE::normalize, OptionBase::nosave, 00101 "Will be set at construction and build time."); 00102 00103 redeclareOption(ol, "ignore_n_first", &LLE::ignore_n_first, OptionBase::nosave, 00104 "Will be set to 1 at construction time."); 00105 00106 } 00107 00109 // build // 00111 void LLE::build() 00112 { 00113 inherited::build(); 00114 build_(); 00115 } 00116 00118 // build_ // 00120 void LLE::build_() 00121 { 00122 if (classical_induction) { 00123 lle_kernel->reconstruct_coeff = -1; 00124 normalize = 2; 00125 } else { 00126 lle_kernel->reconstruct_coeff = this->reconstruct_coeff; 00127 normalize = 1; 00128 } 00129 lle_kernel->knn = this->knn; 00130 lle_kernel->regularizer = this->regularizer; 00131 lle_kernel->report_progress = this->report_progress; 00132 lle_kernel->build(); 00133 this->kernel = (Kernel*) lle_kernel; 00134 } 00135 00137 // forget // 00139 void LLE::forget() 00140 { 00141 inherited::forget(); 00142 } 00143 00145 // makeDeepCopyFromShallowCopy // 00147 void LLE::makeDeepCopyFromShallowCopy(map<const void*, void*>& copies) 00148 { 00149 inherited::makeDeepCopyFromShallowCopy(copies); 00150 00151 // ### Call deepCopyField on all "pointer-like" fields 00152 // ### that you wish to be deepCopied rather than 00153 // ### shallow-copied. 00154 // ### ex: 00155 // deepCopyField(trainvec, copies); 00156 00157 // ### Remove this line when you have fully implemented this method. 00158 PLERROR("LLE::makeDeepCopyFromShallowCopy not fully (correctly) implemented yet!"); 00159 } 00160 00161 } // end of namespace PLearn 00162

Generated on Tue Aug 17 15:57:39 2004 for PLearn by doxygen 1.3.7