SHOGUN
v1.1.0
Main Page
Related Pages
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
src
shogun
kernel
WeightedCommWordStringKernel.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) 1999-2009 Soeren Sonnenburg
8
* Written (W) 1999-2008 Gunnar Raetsch
9
* Copyright (C) 1999-2009 Fraunhofer Institute FIRST and Max-Planck-Society
10
*/
11
12
#ifndef _WEIGHTEDCOMMWORDSTRINGKERNEL_H___
13
#define _WEIGHTEDCOMMWORDSTRINGKERNEL_H___
14
15
#include <
shogun/lib/common.h
>
16
#include <
shogun/mathematics/Math.h
>
17
#include <
shogun/kernel/CommWordStringKernel.h
>
18
19
namespace
shogun
20
{
21
class
CCommWordStringKernel;
22
50
class
CWeightedCommWordStringKernel
:
public
CCommWordStringKernel
51
{
52
public
:
54
CWeightedCommWordStringKernel
();
55
61
CWeightedCommWordStringKernel
(int32_t size,
bool
use_sign
);
62
70
CWeightedCommWordStringKernel
(
71
CStringFeatures<uint16_t>
* l,
CStringFeatures<uint16_t>
* r,
72
bool
use_sign=
false
, int32_t size=10);
73
74
virtual
~CWeightedCommWordStringKernel
();
75
82
virtual
bool
init
(
CFeatures
* l,
CFeatures
* r);
83
85
virtual
void
cleanup
();
86
92
virtual
float64_t
compute_optimized
(int32_t idx);
93
99
virtual
void
add_to_normal
(int32_t idx,
float64_t
weight);
100
102
void
merge_normal
();
103
108
bool
set_wd_weights
();
109
116
bool
set_weights
(
float64_t
* w, int32_t d);
117
122
virtual
EKernelType
get_kernel_type
() {
return
K_WEIGHTEDCOMMWORDSTRING
; }
123
128
virtual
const
char
*
get_name
()
const
{
return
"WeightedCommWordStringKernel"
; }
129
134
inline
virtual
EFeatureType
get_feature_type
() {
return
F_WORD
; }
135
148
virtual
float64_t
*
compute_scoring
(
149
int32_t max_degree, int32_t& num_feat, int32_t& num_sym,
150
float64_t
* target, int32_t num_suppvec, int32_t* IDX,
151
float64_t
* alphas,
bool
do_init=
true
);
152
153
protected
:
160
virtual
float64_t
compute_helper
(
161
int32_t idx_a, int32_t idx_b,
bool
do_sort);
162
163
private
:
164
void
init();
165
166
protected
:
168
int32_t
degree
;
169
171
float64_t
*
weights
;
172
};
173
}
174
#endif
/* _WEIGHTEDCOMMWORDSTRINGKERNEL_H__ */
SHOGUN
Machine Learning Toolbox - Documentation