SHOGUN
v3.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
features
ImplicitWeightedSpecFeatures.h
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) 2009-2010 Soeren Sonnenburg
8
* Copyright (C) 2009 Fraunhofer Institute FIRST and Max-Planck-Society
9
* Copyright (C) 2010 Berlin Institute of Technology
10
*/
11
12
#ifndef _IMPLICITSPECFEATURES_H___
13
#define _IMPLICITSPECFEATURES_H___
14
15
#include <
shogun/lib/common.h
>
16
#include <
shogun/io/SGIO.h
>
17
#include <
shogun/features/DotFeatures.h
>
18
#include <
shogun/features/StringFeatures.h
>
19
20
namespace
shogun
21
{
22
23
template
<
class
ST>
class
CStringFeatures;
24
30
class
CImplicitWeightedSpecFeatures
:
public
CDotFeatures
31
{
32
public
:
34
CImplicitWeightedSpecFeatures
();
35
41
CImplicitWeightedSpecFeatures
(
CStringFeatures<uint16_t>
* str,
bool
normalize=
true
);
42
44
CImplicitWeightedSpecFeatures
(
const
CImplicitWeightedSpecFeatures
& orig);
45
46
virtual
~CImplicitWeightedSpecFeatures
();
47
52
virtual
CFeatures
*
duplicate
()
const
;
53
61
virtual
int32_t
get_dim_feature_space
()
const
;
62
70
virtual
float64_t
dot
(int32_t vec_idx1,
CDotFeatures
* df, int32_t vec_idx2);
71
78
virtual
float64_t
dense_dot
(int32_t vec_idx1,
const
float64_t
* vec2, int32_t vec2_len);
79
88
virtual
void
add_to_dense_vec
(
float64_t
alpha, int32_t vec_idx1,
89
float64_t
* vec2, int32_t vec2_len,
bool
abs_val=
false
);
90
96
virtual
int32_t
get_nnz_features_for_vector
(int32_t num);
97
102
virtual
EFeatureType
get_feature_type
()
const
;
103
108
virtual
EFeatureClass
get_feature_class
()
const
;
109
114
virtual
int32_t
get_num_vectors
()
const
;
115
120
bool
set_wd_weights
();
121
128
bool
set_weights
(
float64_t
* w, int32_t d);
129
130
#ifndef DOXYGEN_SHOULD_SKIP_THIS
131
132
struct
wspec_feature_iterator
133
{
135
uint16_t* vec;
137
int32_t vidx;
139
int32_t vlen;
141
bool
vfree;
142
147
int32_t offs;
148
int32_t d;
149
int32_t j;
150
uint8_t mask;
151
float64_t
alpha;
153
};
154
#endif
155
165
virtual
void
*
get_feature_iterator
(int32_t vector_index);
166
177
virtual
bool
get_next_feature
(int32_t& index,
float64_t
& value,
void
* iterator);
178
184
virtual
void
free_feature_iterator
(
void
* iterator);
185
187
virtual
const
char
*
get_name
()
const
{
return
"ImplicitWeightedSpecFeatures"
; }
188
189
protected
:
194
void
compute_normalization_const
();
195
196
protected
:
198
CStringFeatures<uint16_t>
*
strings
;
199
201
float64_t
*
normalization_factors
;
203
int32_t
num_strings
;
205
int32_t
alphabet_size
;
206
208
int32_t
degree
;
210
int32_t
spec_size
;
211
213
float64_t
*
spec_weights
;
214
};
215
}
216
#endif // _IMPLICITSPECFEATURES_H___
SHOGUN
Machine Learning Toolbox - Documentation