SHOGUN
v2.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
ui
GUIConverter.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) 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
31
using namespace
shogun;
32
33
CGUIConverter::CGUIConverter
(CSGInterface* ui)
34
:
CSGObject
(), m_ui(ui)
35
{
36
m_converter
= NULL;
37
}
38
39
CGUIConverter::~CGUIConverter
()
40
{
41
SG_UNREF
(
m_converter
);
42
}
43
44
bool
CGUIConverter::create_locallylinearembedding
(int32_t k)
45
{
46
#ifdef HAVE_LAPACK
47
m_converter
=
new
CLocallyLinearEmbedding
();
48
((
CLocallyLinearEmbedding
*)
m_converter
)->set_k(k);
49
#else
50
SG_ERROR
(
"Requires Lapack to be enabled at compile time\n"
);
51
#endif
52
return
true
;
53
}
54
55
bool
CGUIConverter::create_neighborhoodpreservingembedding
(int32_t k)
56
{
57
#ifdef HAVE_LAPACK
58
m_converter
=
new
CNeighborhoodPreservingEmbedding
();
59
((
CNeighborhoodPreservingEmbedding
*)
m_converter
)->set_k(k);
60
#else
61
SG_ERROR
(
"Requires Lapack to be enabled at compile time\n"
);
62
#endif
63
return
true
;
64
}
65
66
bool
CGUIConverter::create_localtangentspacealignment
(int32_t k)
67
{
68
#ifdef HAVE_LAPACK
69
m_converter
=
new
CLocalTangentSpaceAlignment
();
70
((
CLocalTangentSpaceAlignment
*)
m_converter
)->set_k(k);
71
#else
72
SG_ERROR
(
"Requires Lapack to be enabled at compile time\n"
);
73
#endif
74
return
true
;
75
}
76
77
bool
CGUIConverter::create_linearlocaltangentspacealignment
(int32_t k)
78
{
79
#ifdef HAVE_LAPACK
80
m_converter
=
new
CLinearLocalTangentSpaceAlignment
();
81
((
CLinearLocalTangentSpaceAlignment
*)
m_converter
)->set_k(k);
82
#else
83
SG_ERROR
(
"Requires Lapack to be enabled at compile time\n"
);
84
#endif
85
return
true
;
86
}
87
88
bool
CGUIConverter::create_hessianlocallylinearembedding
(int32_t k)
89
{
90
#ifdef HAVE_LAPACK
91
m_converter
=
new
CLocallyLinearEmbedding
();
92
((
CHessianLocallyLinearEmbedding
*)
m_converter
)->set_k(k);
93
#else
94
SG_ERROR
(
"Requires Lapack to be enabled at compile time\n"
);
95
#endif
96
return
true
;
97
}
98
99
bool
CGUIConverter::create_laplacianeigenmaps
(int32_t k,
float64_t
width)
100
{
101
#ifdef HAVE_LAPACK
102
m_converter
=
new
CLaplacianEigenmaps
();
103
((
CLaplacianEigenmaps
*)
m_converter
)->set_k(k);
104
((
CLaplacianEigenmaps
*)
m_converter
)->set_tau(width);
105
#else
106
SG_ERROR
(
"Requires Lapack to be enabled at compile time\n"
);
107
#endif
108
return
true
;
109
}
110
111
bool
CGUIConverter::create_localitypreservingprojections
(int32_t k,
float64_t
width)
112
{
113
#ifdef HAVE_LAPACK
114
m_converter
=
new
CLocalityPreservingProjections
();
115
((
CLocalityPreservingProjections
*)
m_converter
)->set_k(k);
116
((
CLocalityPreservingProjections
*)
m_converter
)->set_tau(width);
117
#else
118
SG_ERROR
(
"Requires Lapack to be enabled at compile time\n"
);
119
#endif
120
return
true
;
121
}
122
123
bool
CGUIConverter::create_diffusionmaps
(int32_t t,
float64_t
width)
124
{
125
#ifdef HAVE_LAPACK
126
m_converter
=
new
CDiffusionMaps
();
127
((
CDiffusionMaps
*)
m_converter
)->set_t(t);
128
((
CDiffusionMaps
*)
m_converter
)->set_kernel(
new
CGaussianKernel
(100,width));
129
#else
130
SG_ERROR
(
"Requires Lapack to be enabled at compile time\n"
);
131
#endif
132
return
true
;
133
}
134
135
bool
CGUIConverter::create_isomap
(int32_t k)
136
{
137
#ifdef HAVE_LAPACK
138
m_converter
=
new
CIsomap
();
139
((
CIsomap
*)
m_converter
)->set_k(k);
140
#else
141
SG_ERROR
(
"Requires Lapack to be enabled at compile time\n"
);
142
#endif
143
return
true
;
144
}
145
146
bool
CGUIConverter::create_multidimensionalscaling
()
147
{
148
#ifdef HAVE_LAPACK
149
m_converter
=
new
CMultidimensionalScaling
();
150
#else
151
SG_ERROR
(
"Requires Lapack to be enabled at compile time\n"
);
152
#endif
153
return
true
;
154
}
155
156
CDenseFeatures<float64_t>
*
CGUIConverter::embed
(int32_t target_dim)
157
{
158
if
(!
m_converter
)
159
SG_ERROR
(
"No converter created"
);
160
((
CEmbeddingConverter
*)
m_converter
)->set_target_dim(target_dim);
161
return
((
CEmbeddingConverter
*)
m_converter
)->embed(
m_ui
->ui_features->get_train_features());
162
}
163
SHOGUN
Machine Learning Toolbox - Documentation