SHOGUN  4.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
LocallyLinearEmbedding.cpp
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 3 of the License, or
5  * (at your option) any later version.
6  *
7  * Written (W) 2011 Sergey Lisitsyn
8  * Copyright (C) 2011 Berlin Institute of Technology and Max-Planck-Society
9  */
10 
12 #include <shogun/lib/config.h>
13 #ifdef HAVE_EIGEN3
16 #include <shogun/io/SGIO.h>
17 #include <shogun/lib/Time.h>
18 #include <shogun/lib/tapkee/tapkee_shogun.hpp>
19 
20 using namespace shogun;
21 
24 {
25  m_k = 10;
26  m_nullspace_shift = -1e-9;
28  init();
29 }
30 
32 {
33  SG_ADD(&m_k, "k", "number of neighbors", MS_AVAILABLE);
34  SG_ADD(&m_nullspace_shift, "nullspace_shift",
35  "nullspace finding regularization shift",MS_NOT_AVAILABLE);
36  SG_ADD(&m_reconstruction_shift, "reconstruction_shift",
37  "shift used to regularize reconstruction step", MS_NOT_AVAILABLE);
38 }
39 
40 
42 {
43 }
44 
46 {
47  ASSERT(k>0)
48  m_k = k;
49 }
50 
52 {
53  return m_k;
54 }
55 
57 {
58  m_nullspace_shift = nullspace_shift;
59 }
60 
62 {
63  return m_nullspace_shift;
64 }
65 
67 {
68  m_reconstruction_shift = reconstruction_shift;
69 }
70 
72 {
74 }
75 
77 {
78  return "LocallyLinearEmbedding";
79 }
80 
82 {
83  // oh my let me dirty cast it
84  CKernel* kernel = new CLinearKernel((CDotFeatures*)features,(CDotFeatures*)features);
85  TAPKEE_PARAMETERS_FOR_SHOGUN parameters;
86  parameters.n_neighbors = m_k;
87  parameters.eigenshift = m_nullspace_shift;
88  parameters.method = SHOGUN_LOCALLY_LINEAR_EMBEDDING;
89  parameters.target_dimension = m_target_dim;
90  parameters.kernel = kernel;
91  CDenseFeatures<float64_t>* embedding = tapkee_embed(parameters);
92  SG_UNREF(kernel);
93  return embedding;
94 }
95 
96 #endif /* HAVE_EIGEN3 */
Computes the standard linear kernel on CDotFeatures.
Definition: LinearKernel.h:35
class EmbeddingConverter (part of the Efficient Dimensionality Reduction Toolkit) used to construct e...
void set_reconstruction_shift(float64_t reconstruction_shift)
virtual const char * get_name() const
Features that support dot products among other operations.
Definition: DotFeatures.h:44
#define ASSERT(x)
Definition: SGIO.h:201
double float64_t
Definition: common.h:50
virtual CFeatures * apply(CFeatures *features)
void set_nullspace_shift(float64_t nullspace_shift)
#define SG_UNREF(x)
Definition: SGObject.h:52
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:18
The class Features is the base class of all feature objects.
Definition: Features.h:68
The Kernel base class.
Definition: Kernel.h:158
#define SG_ADD(...)
Definition: SGObject.h:81

SHOGUN Machine Learning Toolbox - Documentation