SHOGUN
3.2.1
首页
相关页面
模块
类
文件
文件列表
文件成员
全部
类
命名空间
文件
函数
变量
类型定义
枚举
枚举值
友元
宏定义
组
页
src
shogun
converter
LocallyLinearEmbedding.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/LocallyLinearEmbedding.h
>
12
#include <
shogun/lib/config.h
>
13
#ifdef HAVE_EIGEN3
14
#include <
shogun/converter/EmbeddingConverter.h
>
15
#include <
shogun/kernel/LinearKernel.h
>
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
22
CLocallyLinearEmbedding::CLocallyLinearEmbedding
() :
23
CEmbeddingConverter
()
24
{
25
m_k
= 10;
26
m_nullspace_shift
= -1e-9;
27
m_reconstruction_shift
= 1e-3;
28
init
();
29
}
30
31
void
CLocallyLinearEmbedding::init
()
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
41
CLocallyLinearEmbedding::~CLocallyLinearEmbedding
()
42
{
43
}
44
45
void
CLocallyLinearEmbedding::set_k
(int32_t k)
46
{
47
ASSERT
(k>0)
48
m_k
= k;
49
}
50
51
int32_t
CLocallyLinearEmbedding::get_k
()
const
52
{
53
return
m_k
;
54
}
55
56
void
CLocallyLinearEmbedding::set_nullspace_shift
(
float64_t
nullspace_shift)
57
{
58
m_nullspace_shift
= nullspace_shift;
59
}
60
61
float64_t
CLocallyLinearEmbedding::get_nullspace_shift
()
const
62
{
63
return
m_nullspace_shift
;
64
}
65
66
void
CLocallyLinearEmbedding::set_reconstruction_shift
(
float64_t
reconstruction_shift)
67
{
68
m_reconstruction_shift
= reconstruction_shift;
69
}
70
71
float64_t
CLocallyLinearEmbedding::get_reconstruction_shift
()
const
72
{
73
return
m_reconstruction_shift
;
74
}
75
76
const
char
*
CLocallyLinearEmbedding::get_name
()
const
77
{
78
return
"LocallyLinearEmbedding"
;
79
}
80
81
CFeatures
*
CLocallyLinearEmbedding::apply
(
CFeatures
* features)
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 */
SHOGUN
机器学习工具包 - 项目文档