00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00044
#include "LLE.h"
00045
00046
namespace PLearn {
00047
using namespace std;
00048
00050
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;
00060 this->ignore_n_first = 1;
00061 }
00062
00063
PLEARN_IMPLEMENT_OBJECT(
LLE,
00064
"Performs Locally Linear Embedding.",
00065
""
00066 );
00067
00069
00071 void LLE::declareOptions(
OptionList& ol)
00072 {
00073
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
00089
00090
declareOption(ol,
"lle_kernel", &LLE::lle_kernel, OptionBase::learntoption,
00091
"The kernel used in LLE.");
00092
00093
00094 inherited::declareOptions(ol);
00095
00096
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
00111 void LLE::build()
00112 {
00113 inherited::build();
00114
build_();
00115 }
00116
00118
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
00139 void LLE::forget()
00140 {
00141 inherited::forget();
00142 }
00143
00145
00147 void LLE::makeDeepCopyFromShallowCopy(map<const void*, void*>& copies)
00148 {
00149 inherited::makeDeepCopyFromShallowCopy(copies);
00150
00151
00152
00153
00154
00155
00156
00157
00158
PLERROR(
"LLE::makeDeepCopyFromShallowCopy not fully (correctly) implemented yet!");
00159 }
00160
00161 }
00162