SHOGUN  4.1.0
 全部  命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义  
CommWordStringKernel.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 _COMMWORDSTRINGKERNEL_H___
13 #define _COMMWORDSTRINGKERNEL_H___
14 
15 #include <shogun/lib/config.h>
16 
17 #include <shogun/lib/common.h>
20 
21 namespace shogun
22 {
48 class CCommWordStringKernel : public CStringKernel<uint16_t>
49 {
53  friend class CRidgeKernelNormalizer;
56  friend class CDiceKernelNormalizer;
57 
58  public:
61 
67  CCommWordStringKernel(int32_t size, bool use_sign);
68 
78  bool use_sign=false, int32_t size=10);
79 
80  virtual ~CCommWordStringKernel();
81 
88  virtual bool init(CFeatures* l, CFeatures* r);
89 
91  virtual void cleanup();
92 
98 
103  virtual const char* get_name() const { return "CommWordStringKernel"; }
104 
109  virtual bool init_dictionary(int32_t size);
110 
118  virtual bool init_optimization(
119  int32_t count, int32_t *IDX, float64_t* weights);
120 
125  virtual bool delete_optimization();
126 
132  virtual float64_t compute_optimized(int32_t idx);
133 
139  virtual void add_to_normal(int32_t idx, float64_t weight);
140 
142  virtual void clear_normal();
143 
148  virtual EFeatureType get_feature_type() { return F_WORD; }
149 
155  void get_dictionary(int32_t& dsize, float64_t*& dweights)
156  {
157  dsize=dictionary_size;
158  dweights = dictionary_weights;
159  }
160 
173  virtual float64_t* compute_scoring(
174  int32_t max_degree, int32_t& num_feat, int32_t& num_sym,
175  float64_t* target, int32_t num_suppvec, int32_t* IDX,
176  float64_t* alphas, bool do_init=true);
177 
186  char* compute_consensus(
187  int32_t &num_feat, int32_t num_suppvec, int32_t* IDX,
188  float64_t* alphas);
189 
195  {
197  }
198 
204  {
206  }
207 
208  protected:
217  virtual float64_t compute(int32_t idx_a, int32_t idx_b)
218  {
219  return compute_helper(idx_a, idx_b, false);
220  }
221 
229  virtual float64_t compute_helper(
230  int32_t idx_a, int32_t idx_b, bool do_sort);
231 
237  virtual float64_t compute_diag(int32_t idx_a);
238 
239  private:
240  void init();
241 
242  protected:
248 
250  bool use_sign;
251 
256 };
257 }
258 #endif /* _COMMWORDSTRINGKERNEL_H__ */
virtual float64_t compute_optimized(int32_t idx)
void set_use_dict_diagonal_optimization(bool flag)
virtual bool init_optimization(int32_t count, int32_t *IDX, float64_t *weights)
EKernelType
Definition: Kernel.h:57
virtual bool init_dictionary(int32_t size)
DiceKernelNormalizer performs kernel normalization inspired by the Dice coefficient (see http://en...
virtual float64_t compute(int32_t idx_a, int32_t idx_b)
virtual EFeatureType get_feature_type()
TanimotoKernelNormalizer performs kernel normalization inspired by the Tanimoto coefficient (see http...
virtual float64_t compute_helper(int32_t idx_a, int32_t idx_b, bool do_sort)
virtual float64_t compute_diag(int32_t idx_a)
The CommWordString kernel may be used to compute the spectrum kernel from strings that have been mapp...
double float64_t
Definition: common.h:50
Normalize the kernel by a constant obtained from the first element of the kernel matrix, i.e. .
Normalize the kernel by adding a constant term to its diagonal. This aids kernels to become positive ...
virtual EKernelType get_kernel_type()
virtual bool init(CFeatures *l, CFeatures *r)
virtual const char * get_name() const
EFeatureType
shogun feature type
Definition: FeatureTypes.h:19
void get_dictionary(int32_t &dsize, float64_t *&dweights)
SqrtDiagKernelNormalizer divides by the Square Root of the product of the diagonal elements...
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:18
virtual float64_t * compute_scoring(int32_t max_degree, int32_t &num_feat, int32_t &num_sym, float64_t *target, int32_t num_suppvec, int32_t *IDX, float64_t *alphas, bool do_init=true)
Normalize the kernel by either a constant or the average value of the diagonal elements (depending on...
The class Features is the base class of all feature objects.
Definition: Features.h:68
char * compute_consensus(int32_t &num_feat, int32_t num_suppvec, int32_t *IDX, float64_t *alphas)
virtual void add_to_normal(int32_t idx, float64_t weight)
Template class StringKernel, is the base class of all String Kernels.
Definition: StringKernel.h:26
VarianceKernelNormalizer divides by the ``variance''.

SHOGUN 机器学习工具包 - 项目文档