SHOGUN
3.2.1
首页
相关页面
模块
类
文件
文件列表
文件成员
全部
类
命名空间
文件
函数
变量
类型定义
枚举
枚举值
友元
宏定义
组
页
src
shogun
converter
DiffusionMaps.cpp
浏览该文件的文档.
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
11
#include <
shogun/converter/DiffusionMaps.h
>
12
#include <
shogun/converter/EmbeddingConverter.h
>
13
#include <
shogun/lib/config.h
>
14
#ifdef HAVE_EIGEN3
15
#include <
shogun/distance/EuclideanDistance.h
>
16
#include <shogun/lib/tapkee/tapkee_shogun.hpp>
17
18
using namespace
shogun;
19
20
CDiffusionMaps::CDiffusionMaps
() :
21
CEmbeddingConverter
()
22
{
23
m_t
= 10;
24
m_width
= 1.0;
25
set_distance
(
new
CEuclideanDistance
());
26
27
init
();
28
}
29
30
void
CDiffusionMaps::init
()
31
{
32
SG_ADD
(&
m_t
,
"t"
,
"number of steps"
,
MS_AVAILABLE
);
33
SG_ADD
(&
m_width
,
"width"
,
"gaussian kernel width"
,
MS_AVAILABLE
);
34
}
35
36
CDiffusionMaps::~CDiffusionMaps
()
37
{
38
}
39
40
void
CDiffusionMaps::set_t
(int32_t t)
41
{
42
m_t
= t;
43
}
44
45
int32_t
CDiffusionMaps::get_t
()
const
46
{
47
return
m_t
;
48
}
49
50
void
CDiffusionMaps::set_width
(
float64_t
width)
51
{
52
m_width
= width;
53
}
54
55
float64_t
CDiffusionMaps::get_width
()
const
56
{
57
return
m_width
;
58
}
59
60
const
char
*
CDiffusionMaps::get_name
()
const
61
{
62
return
"DiffusionMaps"
;
63
};
64
65
CFeatures
*
CDiffusionMaps::apply
(
CFeatures
* features)
66
{
67
ASSERT
(features)
68
// shorthand for simplefeatures
69
SG_REF
(features);
70
// compute distance matrix
71
ASSERT
(
m_distance
)
72
m_distance
->
init
(features,features);
73
CDenseFeatures<float64_t>
* embedding =
embed_distance
(
m_distance
);
74
m_distance
->
cleanup
();
75
SG_UNREF
(features);
76
return
(
CFeatures
*)embedding;
77
}
78
79
CDenseFeatures<float64_t>
*
CDiffusionMaps::embed_distance
(
CDistance
*
distance
)
80
{
81
TAPKEE_PARAMETERS_FOR_SHOGUN parameters;
82
parameters.n_timesteps =
m_t
;
83
parameters.gaussian_kernel_width =
m_width
;
84
parameters.method = SHOGUN_DIFFUSION_MAPS;
85
parameters.target_dimension =
m_target_dim
;
86
parameters.distance =
distance
;
87
return
tapkee_embed(parameters);
88
}
89
#endif
/* HAVE_EIGEN3 */
SHOGUN
机器学习工具包 - 项目文档