SHOGUN  4.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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/config.h>
15 
16 #include <shogun/lib/common.h>
20 
21 namespace shogun
22 {
32 {
33  public:
36 
43  CSalzbergWordStringKernel(int32_t size, CPluginEstimate* pie, CLabels* labels=NULL);
44 
54  CPluginEstimate *pie, CLabels* labels=NULL);
55 
57 
63  void set_prior_probs(float64_t pos_prior_, float64_t neg_prior_)
64  {
65  pos_prior=pos_prior_ ;
66  neg_prior=neg_prior_ ;
67  if (fabs(pos_prior+neg_prior-1)>1e-6)
68  SG_WARNING("priors don't sum to 1: %f+%f-1=%f\n", pos_prior, neg_prior, pos_prior+neg_prior-1)
69  };
70 
76 
83  virtual bool init(CFeatures* l, CFeatures* r);
84 
86  virtual void cleanup();
87 
92  virtual EKernelType get_kernel_type() { return K_SALZBERG; }
93 
98  virtual const char* get_name() const { return "SalzbergWordStringKernel" ; }
99 
100  protected:
109  float64_t compute(int32_t idx_a, int32_t idx_b);
110  // float64_t compute_slow(int64_t idx_a, int64_t idx_b);
111 
118  inline int32_t compute_index(int32_t position, uint16_t symbol)
119  {
120  return position*num_symbols+symbol;
121  }
122  private:
123  void init();
124 
125  protected:
128 
133 
138 
143 
145  int32_t num_params;
147  int32_t num_symbols;
156 };
157 }
158 #endif /* _SALZBERGWORDKERNEL_H__ */
EKernelType
Definition: Kernel.h:57
The class Labels models labels, i.e. class assignments of objects.
Definition: Labels.h:43
int32_t compute_index(int32_t position, uint16_t symbol)
The SalzbergWordString kernel implements the Salzberg kernel.
float64_t compute(int32_t idx_a, int32_t idx_b)
double float64_t
Definition: common.h:50
virtual const char * get_name() const
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:18
void set_prior_probs(float64_t pos_prior_, float64_t neg_prior_)
The class Features is the base class of all feature objects.
Definition: Features.h:68
class PluginEstimate
#define SG_WARNING(...)
Definition: SGIO.h:128
Template class StringKernel, is the base class of all String Kernels.
Definition: StringKernel.h:26

SHOGUN Machine Learning Toolbox - Documentation