SHOGUN
3.2.1
首页
相关页面
模块
类
文件
文件列表
文件成员
全部
类
命名空间
文件
函数
变量
类型定义
枚举
枚举值
友元
宏定义
组
页
src
shogun
ui
GUIFeatures.h
浏览该文件的文档.
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) 1999-2008 Soeren Sonnenburg
8
* Written (W) 1999-2008 Gunnar Raetsch
9
* Copyright (C) 1999-2008 Fraunhofer Institute FIRST and Max-Planck-Society
10
*/
11
12
#ifndef __GUIFEATURES__H
13
#define __GUIFEATURES__H
14
15
#include <
shogun/lib/config.h
>
16
#include <
shogun/base/SGObject.h
>
17
#include <
shogun/labels/Labels.h
>
18
#include <
shogun/features/Features.h
>
19
#include <
shogun/features/RealFileFeatures.h
>
20
#include <
shogun/features/TOPFeatures.h
>
21
#include <
shogun/features/FKFeatures.h
>
22
#include <
shogun/features/StringFeatures.h
>
23
#include <
shogun/features/DenseFeatures.h
>
24
#include <
shogun/features/SparseFeatures.h
>
25
#include <
shogun/features/CombinedFeatures.h
>
26
#include <
shogun/features/CombinedDotFeatures.h
>
27
#include <
shogun/features/WDFeatures.h
>
28
#include <
shogun/features/ExplicitSpecFeatures.h
>
29
#include <
shogun/features/ImplicitWeightedSpecFeatures.h
>
30
31
namespace
shogun
32
{
33
class
CSGInterface;
34
36
class
CGUIFeatures
:
public
CSGObject
37
{
39
enum
EFeatureType
40
{
41
Simple,
42
Sparse
43
};
44
45
public
:
47
CGUIFeatures
() {};
51
CGUIFeatures
(CSGInterface*
interface
);
53
~CGUIFeatures
();
54
56
inline
CFeatures
*
get_train_features
() {
return
train_features
; }
58
inline
CFeatures
*
get_test_features
() {
return
test_features
; }
59
63
inline
bool
set_train_features
(
CFeatures
* f)
64
{
65
//invalidate_train();
66
SG_REF
(f);
67
SG_UNREF
(
train_features
);
68
train_features
=f;
69
return
true
;
70
}
71
75
inline
bool
set_test_features
(
CFeatures
* f)
76
{
77
//invalidate_test();
78
SG_REF
(f);
79
SG_UNREF
(
test_features
);
80
test_features
=f;
81
return
true
;
82
}
83
87
void
add_train_features
(
CFeatures
* f);
91
void
add_test_features
(
CFeatures
* f);
95
void
add_train_dotfeatures
(
CDotFeatures
* f);
99
void
add_test_dotfeatures
(
CDotFeatures
* f);
100
102
bool
del_last_feature_obj
(
char
* target);
103
105
void
invalidate_train
();
107
void
invalidate_test
();
108
110
bool
load
(
111
char
* filename,
char
* fclass,
char
* type,
char
* target,
112
int32_t size, int32_t comp_features);
114
bool
save
(
char
* filename,
char
* type,
char
* target);
116
bool
clean
(
char
* target);
118
bool
reshape
(
char
* target, int32_t num_feat, int32_t num_vec);
119
121
CFeatures
*
get_convert_features
(
char
* target);
123
bool
set_convert_features
(
CFeatures
* features,
char
* target);
124
128
CSparseFeatures<float64_t>
*
convert_simple_real_to_sparse_real
(
129
CDenseFeatures<float64_t>
* src);
133
CStringFeatures<char>
*
convert_simple_char_to_string_char
(
134
CDenseFeatures<char>
* src);
139
CDenseFeatures<float64_t>
*
convert_simple_char_to_simple_align
(
140
CDenseFeatures<char>
* src,
141
float64_t
gap_cost=0);
145
CDenseFeatures<float64_t>
*
convert_simple_word_to_simple_salzberg
(
146
CDenseFeatures<uint16_t>
* src);
147
151
CTOPFeatures
*
convert_string_word_to_simple_top
(
152
CStringFeatures<uint16_t>
* src);
156
CFKFeatures
*
convert_string_word_to_simple_fk
(
157
CStringFeatures<uint16_t>
* src);
161
CDenseFeatures<float64_t>
*
convert_sparse_real_to_simple_real
(
162
CSparseFeatures<float64_t>
* src);
167
CExplicitSpecFeatures
*
convert_string_byte_to_spec_word
(
168
CStringFeatures<uint16_t>
* src,
bool
use_norm);
169
178
template
<
class
CT,
class
ST>
179
CStringFeatures<ST>
*
convert_string_char_to_string_generic
(
180
CStringFeatures<CT>
* src,
181
int32_t order=1, int32_t start=0, int32_t gap=0,
char
rev=
'f'
,
CAlphabet
* alpha=NULL)
182
{
183
if
(src && src->
get_feature_class
()==
C_STRING
)
184
{
185
//create dense features with 0 cache
186
SG_INFO
(
"Converting CT STRING features to ST STRING ones (order=%i).\n"
,order)
187
bool
free_alpha=
false
;
188
189
if
(!alpha)
190
{
191
CAlphabet
* a = src->
get_alphabet
();
192
193
if
( a && a->
get_alphabet
() ==
DNA
)
194
alpha=
new
CAlphabet
(
RAWDNA
);
195
else
196
alpha=
new
CAlphabet
(a);
197
198
free_alpha=
true
;
199
SG_UNREF
(a);
200
}
201
202
CStringFeatures<ST>
* sf=
new
CStringFeatures<ST>
(alpha);
203
if
(sf && sf->
obtain_from_char_features
(src, start, order, gap, rev==
'r'
))
204
{
205
SG_INFO
(
"Conversion was successful.\n"
)
206
return
sf;
207
}
208
209
if
(free_alpha)
210
SG_UNREF
(alpha);
211
SG_UNREF
(sf);
212
}
213
else
214
SG_ERROR
(
"No features of class/type STRING/CT available.\n"
)
215
216
return
NULL;
217
}
218
219
221
bool
set_reference_features
(
char
* target);
222
224
virtual
const
char
*
get_name
()
const
{
return
"GUIFeatures"
; }
225
226
protected
:
228
CSGInterface*
ui
;
230
CFeatures
*
train_features
;
232
CFeatures
*
test_features
;
234
CFeatures
*
ref_features
;
235
};
236
}
237
#endif
SHOGUN
机器学习工具包 - 项目文档