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
kernel
string
SalzbergWordStringKernel.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-2008 Gunnar Raetsch
8
* Copyright (C) 1999-2009 Fraunhofer Institute FIRST and Max-Planck-Society
9
*/
10
11
#ifndef _SALZBERGWORDSTRINGKERNEL_H___
12
#define _SALZBERGWORDSTRINGKERNEL_H___
13
14
#include <
shogun/lib/common.h
>
15
#include <
shogun/kernel/string/StringKernel.h
>
16
#include <
shogun/classifier/PluginEstimate.h
>
17
#include <
shogun/features/StringFeatures.h
>
18
19
namespace
shogun
20
{
29
class
CSalzbergWordStringKernel
:
public
CStringKernel
<uint16_t>
30
{
31
public
:
33
CSalzbergWordStringKernel
();
34
41
CSalzbergWordStringKernel
(int32_t size,
CPluginEstimate
* pie,
CLabels
* labels=NULL);
42
50
CSalzbergWordStringKernel
(
51
CStringFeatures<uint16_t>
* l,
CStringFeatures<uint16_t>
* r,
52
CPluginEstimate
*pie,
CLabels
* labels=NULL);
53
54
virtual
~CSalzbergWordStringKernel
();
55
61
void
set_prior_probs
(
float64_t
pos_prior_,
float64_t
neg_prior_)
62
{
63
pos_prior
=pos_prior_ ;
64
neg_prior
=neg_prior_ ;
65
if
(fabs(
pos_prior
+
neg_prior
-1)>1e-6)
66
SG_WARNING
(
"priors don't sum to 1: %f+%f-1=%f\n"
,
pos_prior
,
neg_prior
,
pos_prior
+
neg_prior
-1)
67
};
68
73
void
set_prior_probs_from_labels
(
CLabels
* labels);
74
81
virtual
bool
init(
CFeatures
* l,
CFeatures
* r);
82
84
virtual
void
cleanup
();
85
90
virtual
EKernelType
get_kernel_type
() {
return
K_SALZBERG
; }
91
96
virtual
const
char
*
get_name
()
const
{
return
"SalzbergWordStringKernel"
; }
97
98
protected
:
107
float64_t
compute
(int32_t idx_a, int32_t idx_b);
108
// float64_t compute_slow(int64_t idx_a, int64_t idx_b);
109
116
inline
int32_t
compute_index
(int32_t position, uint16_t symbol)
117
{
118
return
position*
num_symbols
+symbol;
119
}
120
private
:
121
void
init();
122
123
protected
:
125
CPluginEstimate
*
estimate
;
126
128
float64_t
*
mean
;
130
float64_t
*
variance
;
131
133
float64_t
*
sqrtdiag_lhs
;
135
float64_t
*
sqrtdiag_rhs
;
136
138
float64_t
*
ld_mean_lhs
;
140
float64_t
*
ld_mean_rhs
;
141
143
int32_t
num_params
;
145
int32_t
num_symbols
;
147
float64_t
sum_m2_s2
;
149
float64_t
pos_prior
;
151
float64_t
neg_prior
;
153
bool
initialized
;
154
};
155
}
156
#endif
/* _SALZBERGWORDKERNEL_H__ */
SHOGUN
Machine Learning Toolbox - Documentation