SHOGUN
3.2.1
首页
相关页面
模块
类
文件
文件列表
文件成员
全部
类
命名空间
文件
函数
变量
类型定义
枚举
枚举值
友元
宏定义
组
页
src
shogun
ui
GUIConverter.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) 2012 Sergey Lisitsyn
8
* Copyright (C) 2012 Sergey Lisitsyn
9
*/
10
11
#include <
shogun/ui/GUIConverter.h
>
12
#include <
shogun/ui/SGInterface.h
>
13
14
#include <
shogun/lib/config.h
>
15
#include <
shogun/io/SGIO.h
>
16
#include <
shogun/features/DenseFeatures.h
>
17
#include <
shogun/kernel/GaussianKernel.h
>
18
19
#include <
shogun/converter/LocallyLinearEmbedding.h
>
20
#include <
shogun/converter/HessianLocallyLinearEmbedding.h
>
21
#include <
shogun/converter/LocalTangentSpaceAlignment.h
>
22
#include <
shogun/converter/NeighborhoodPreservingEmbedding.h
>
23
#include <
shogun/converter/LaplacianEigenmaps.h
>
24
#include <
shogun/converter/LocalityPreservingProjections.h
>
25
#include <
shogun/converter/DiffusionMaps.h
>
26
#include <
shogun/converter/LinearLocalTangentSpaceAlignment.h
>
27
#include <
shogun/converter/MultidimensionalScaling.h
>
28
#include <
shogun/converter/Isomap.h
>
29
#include <
shogun/converter/EmbeddingConverter.h
>
30
#include <
shogun/converter/ica/Jade.h
>
31
32
using namespace
shogun;
33
34
CGUIConverter::CGUIConverter
(CSGInterface* ui)
35
:
CSGObject
(), m_ui(ui)
36
{
37
m_converter
= NULL;
38
}
39
40
CGUIConverter::~CGUIConverter
()
41
{
42
SG_UNREF
(
m_converter
);
43
}
44
45
bool
CGUIConverter::create_locallylinearembedding
(int32_t k)
46
{
47
#ifdef HAVE_EIGEN3
48
m_converter
=
new
CLocallyLinearEmbedding
();
49
((
CLocallyLinearEmbedding
*)
m_converter
)->set_k(k);
50
#else
51
SG_ERROR
(
"Requires EIGEN3 to be enabled at compile time\n"
)
52
#endif
53
return
true
;
54
}
55
56
bool
CGUIConverter::create_neighborhoodpreservingembedding
(int32_t k)
57
{
58
#ifdef HAVE_EIGEN3
59
m_converter
=
new
CNeighborhoodPreservingEmbedding
();
60
((
CNeighborhoodPreservingEmbedding
*)
m_converter
)->set_k(k);
61
#else
62
SG_ERROR
(
"Requires EIGEN3 to be enabled at compile time\n"
)
63
#endif
64
return
true
;
65
}
66
67
bool
CGUIConverter::create_localtangentspacealignment
(int32_t k)
68
{
69
#ifdef HAVE_EIGEN3
70
m_converter
=
new
CLocalTangentSpaceAlignment
();
71
((
CLocalTangentSpaceAlignment
*)
m_converter
)->set_k(k);
72
#else
73
SG_ERROR
(
"Requires EIGEN3 to be enabled at compile time\n"
)
74
#endif
75
return
true
;
76
}
77
78
bool
CGUIConverter::create_linearlocaltangentspacealignment
(int32_t k)
79
{
80
#ifdef HAVE_EIGEN3
81
m_converter
=
new
CLinearLocalTangentSpaceAlignment
();
82
((
CLinearLocalTangentSpaceAlignment
*)
m_converter
)->set_k(k);
83
#else
84
SG_ERROR
(
"Requires EIGEN3 to be enabled at compile time\n"
)
85
#endif
86
return
true
;
87
}
88
89
bool
CGUIConverter::create_hessianlocallylinearembedding
(int32_t k)
90
{
91
#ifdef HAVE_EIGEN3
92
m_converter
=
new
CLocallyLinearEmbedding
();
93
((
CHessianLocallyLinearEmbedding
*)
m_converter
)->set_k(k);
94
#else
95
SG_ERROR
(
"Requires EIGEN3 to be enabled at compile time\n"
)
96
#endif
97
return
true
;
98
}
99
100
bool
CGUIConverter::create_laplacianeigenmaps
(int32_t k,
float64_t
width)
101
{
102
#ifdef HAVE_EIGEN3
103
m_converter
=
new
CLaplacianEigenmaps
();
104
((
CLaplacianEigenmaps
*)
m_converter
)->set_k(k);
105
((
CLaplacianEigenmaps
*)
m_converter
)->set_tau(width);
106
#else
107
SG_ERROR
(
"Requires EIGEN3 to be enabled at compile time\n"
)
108
#endif
109
return
true
;
110
}
111
112
bool
CGUIConverter::create_localitypreservingprojections
(int32_t k,
float64_t
width)
113
{
114
#ifdef HAVE_EIGEN3
115
m_converter
=
new
CLocalityPreservingProjections
();
116
((
CLocalityPreservingProjections
*)
m_converter
)->set_k(k);
117
((
CLocalityPreservingProjections
*)
m_converter
)->set_tau(width);
118
#else
119
SG_ERROR
(
"Requires EIGEN3 to be enabled at compile time\n"
)
120
#endif
121
return
true
;
122
}
123
124
bool
CGUIConverter::create_diffusionmaps
(int32_t t,
float64_t
width)
125
{
126
#ifdef HAVE_EIGEN3
127
m_converter
=
new
CDiffusionMaps
();
128
((
CDiffusionMaps
*)
m_converter
)->set_t(t);
129
((
CDiffusionMaps
*)
m_converter
)->set_kernel(
new
CGaussianKernel
(100,width));
130
#else
131
SG_ERROR
(
"Requires EIGEN3 to be enabled at compile time\n"
)
132
#endif
133
return
true
;
134
}
135
136
bool
CGUIConverter::create_isomap
(int32_t k)
137
{
138
#ifdef HAVE_EIGEN3
139
m_converter
=
new
CIsomap
();
140
((
CIsomap
*)
m_converter
)->set_k(k);
141
#else
142
SG_ERROR
(
"Requires EIGEN3 to be enabled at compile time\n"
)
143
#endif
144
return
true
;
145
}
146
147
bool
CGUIConverter::create_multidimensionalscaling
()
148
{
149
#ifdef HAVE_EIGEN3
150
m_converter
=
new
CMultidimensionalScaling
();
151
#else
152
SG_ERROR
(
"Requires EIGEN3 to be enabled at compile time\n"
)
153
#endif
154
return
true
;
155
}
156
157
bool
CGUIConverter::create_jade
()
158
{
159
#ifdef HAVE_EIGEN3
160
m_converter
=
new
CJade
();
161
#else
162
SG_ERROR
(
"Requires EIGEN3 to be enabled at compile time\n"
)
163
#endif
164
return
true
;
165
}
166
167
CDenseFeatures<float64_t>
*
CGUIConverter::apply
()
168
{
169
if
(!
m_converter
)
170
SG_ERROR
(
"No converter created"
)
171
return
(
CDenseFeatures<float64_t>
*)
m_converter
->
apply
(
m_ui
->ui_features->get_train_features());
172
}
173
174
CDenseFeatures<float64_t>
*
CGUIConverter::embed
(int32_t target_dim)
175
{
176
if
(!
m_converter
)
177
SG_ERROR
(
"No converter created"
)
178
((
CEmbeddingConverter
*)
m_converter
)->set_target_dim(target_dim);
179
return
((
CEmbeddingConverter
*)
m_converter
)->embed(
m_ui
->ui_features->get_train_features());
180
}
181
SHOGUN
机器学习工具包 - 项目文档