SHOGUN
v3.0.0
Main Page
Related Pages
Modules
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
src
shogun
converter
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
11
#include <
shogun/converter/LaplacianEigenmaps.h
>
12
#include <
shogun/converter/EmbeddingConverter.h
>
13
#ifdef HAVE_EIGEN3
14
#include <
shogun/distance/EuclideanDistance.h
>
15
#include <shogun/lib/tapkee/tapkee_shogun.hpp>
16
17
using namespace
shogun;
18
19
CLaplacianEigenmaps::CLaplacianEigenmaps
() :
20
CEmbeddingConverter
()
21
{
22
m_k
= 3;
23
m_tau
= 1.0;
24
25
init
();
26
}
27
28
void
CLaplacianEigenmaps::init
()
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
34
CLaplacianEigenmaps::~CLaplacianEigenmaps
()
35
{
36
}
37
38
void
CLaplacianEigenmaps::set_k
(int32_t k)
39
{
40
ASSERT
(k>0)
41
m_k
= k;
42
}
43
44
int32_t
CLaplacianEigenmaps::get_k
()
const
45
{
46
return
m_k
;
47
}
48
49
void
CLaplacianEigenmaps::set_tau
(
float64_t
tau)
50
{
51
m_tau
= tau;
52
}
53
54
float64_t
CLaplacianEigenmaps::get_tau
()
const
55
{
56
return
m_tau
;
57
}
58
59
const
char
*
CLaplacianEigenmaps::get_name
()
const
60
{
61
return
"LaplacianEigenmaps"
;
62
};
63
64
CFeatures
*
CLaplacianEigenmaps::apply
(
CFeatures
* features)
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)
72
ASSERT
(
m_target_dim
<N)
73
74
// compute distance matrix
75
ASSERT
(
m_distance
)
76
m_distance
->
init
(features,features);
77
CDenseFeatures<float64_t>
* embedding =
embed_distance
(
m_distance
);
78
m_distance
->
remove_lhs_and_rhs
();
79
SG_UNREF
(features);
80
return
(
CFeatures
*)embedding;
81
}
82
83
CDenseFeatures<float64_t>
*
CLaplacianEigenmaps::embed_distance
(
CDistance
*
distance
)
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