SHOGUN  v3.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
LaplacianEigenmaps.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-2013 Sergey Lisitsyn
8  * Copyright (C) 2011-2013 Berlin Institute of Technology and Max-Planck-Society
9  */
10 
13 #ifdef HAVE_EIGEN3
15 #include <shogun/lib/tapkee/tapkee_shogun.hpp>
16 
17 using namespace shogun;
18 
21 {
22  m_k = 3;
23  m_tau = 1.0;
24 
25  init();
26 }
27 
29 {
30  SG_ADD(&m_k, "k", "number of neighbors", MS_AVAILABLE);
31  SG_ADD(&m_tau, "tau", "heat distribution coefficient", MS_AVAILABLE);
32 }
33 
35 {
36 }
37 
39 {
40  ASSERT(k>0)
41  m_k = k;
42 }
43 
45 {
46  return m_k;
47 }
48 
50 {
51  m_tau = tau;
52 }
53 
55 {
56  return m_tau;
57 }
58 
59 const char* CLaplacianEigenmaps::get_name() const
60 {
61  return "LaplacianEigenmaps";
62 };
63 
65 {
66  // shorthand for simplefeatures
67  SG_REF(features);
68 
69  // get dimensionality and number of vectors of data
70  int32_t N = features->get_num_vectors();
71  ASSERT(m_k<N)
73 
74  // compute distance matrix
76  m_distance->init(features,features);
79  SG_UNREF(features);
80  return (CFeatures*)embedding;
81 }
82 
84 {
85  TAPKEE_PARAMETERS_FOR_SHOGUN parameters;
86  parameters.n_neighbors = m_k;
87  parameters.gaussian_kernel_width = m_tau;
88  parameters.method = SHOGUN_LAPLACIAN_EIGENMAPS;
89  parameters.target_dimension = m_target_dim;
90  parameters.distance = distance;
91  return tapkee_embed(parameters);
92 }
93 #endif /* HAVE_EIGEN3 */

SHOGUN Machine Learning Toolbox - Documentation