SHOGUN
3.2.1
首页
相关页面
模块
类
文件
文件列表
文件成员
全部
类
命名空间
文件
函数
变量
类型定义
枚举
枚举值
友元
宏定义
组
页
src
shogun
kernel
string
WeightedCommWordStringKernel.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-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/string/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
115
bool
set_weights
(
SGVector<float64_t>
weights
);
116
121
virtual
EKernelType
get_kernel_type
() {
return
K_WEIGHTEDCOMMWORDSTRING
; }
122
127
virtual
const
char
*
get_name
()
const
{
return
"WeightedCommWordStringKernel"
; }
128
133
virtual
EFeatureType
get_feature_type
() {
return
F_WORD
; }
134
147
virtual
float64_t
*
compute_scoring
(
148
int32_t max_degree, int32_t& num_feat, int32_t& num_sym,
149
float64_t
* target, int32_t num_suppvec, int32_t* IDX,
150
float64_t
* alphas,
bool
do_init=
true
);
151
152
protected
:
159
virtual
float64_t
compute_helper
(
160
int32_t idx_a, int32_t idx_b,
bool
do_sort);
161
162
private
:
163
void
init();
164
165
protected
:
167
int32_t
degree
;
168
170
float64_t
*
weights
;
171
};
172
}
173
#endif
/* _WEIGHTEDCOMMWORDSTRINGKERNEL_H__ */
SHOGUN
机器学习工具包 - 项目文档