SHOGUN  4.2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules 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 
14 #include <shogun/lib/tapkee/tapkee_shogun.hpp>
15 
16 using namespace shogun;
17 
20 {
21  m_k = 3;
22  m_tau = 1.0;
23 
24  init();
25 }
26 
28 {
29  SG_ADD(&m_k, "k", "number of neighbors", MS_AVAILABLE);
30  SG_ADD(&m_tau, "tau", "heat distribution coefficient", MS_AVAILABLE);
31 }
32 
34 {
35 }
36 
38 {
39  ASSERT(k>0)
40  m_k = k;
41 }
42 
44 {
45  return m_k;
46 }
47 
49 {
50  m_tau = tau;
51 }
52 
54 {
55  return m_tau;
56 }
57 
58 const char* CLaplacianEigenmaps::get_name() const
59 {
60  return "LaplacianEigenmaps";
61 };
62 
64 {
65  // shorthand for simplefeatures
66  SG_REF(features);
67 
68  // get dimensionality and number of vectors of data
69  int32_t N = features->get_num_vectors();
70  ASSERT(m_k<N)
72 
73  // compute distance matrix
75  m_distance->init(features,features);
78  SG_UNREF(features);
79  return (CFeatures*)embedding;
80 }
81 
83 {
84  TAPKEE_PARAMETERS_FOR_SHOGUN parameters;
85  parameters.n_neighbors = m_k;
86  parameters.gaussian_kernel_width = m_tau;
87  parameters.method = SHOGUN_LAPLACIAN_EIGENMAPS;
88  parameters.target_dimension = m_target_dim;
89  parameters.distance = distance;
90  return tapkee_embed(parameters);
91 }
float distance(CJLCoverTreePoint p1, CJLCoverTreePoint p2, float64_t upper_bound)
Class Distance, a base class for all the distances used in the Shogun toolbox.
Definition: Distance.h:87
class EmbeddingConverter (part of the Efficient Dimensionality Reduction Toolkit) used to construct e...
virtual int32_t get_num_vectors() const =0
virtual CDenseFeatures< float64_t > * embed_distance(CDistance *distance)
#define SG_REF(x)
Definition: SGObject.h:54
#define ASSERT(x)
Definition: SGIO.h:201
virtual void remove_lhs_and_rhs()
Definition: Distance.cpp:144
double float64_t
Definition: common.h:50
#define SG_UNREF(x)
Definition: SGObject.h:55
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:18
virtual CFeatures * apply(CFeatures *features)
The class Features is the base class of all feature objects.
Definition: Features.h:68
#define SG_ADD(...)
Definition: SGObject.h:84
virtual bool init(CFeatures *lhs, CFeatures *rhs)
Definition: Distance.cpp:78
virtual const char * get_name() const

SHOGUN Machine Learning Toolbox - Documentation