SHOGUN  v3.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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/common.h>
18 
19 namespace shogun
20 {
30 {
31  public:
34 
41  CSalzbergWordStringKernel(int32_t size, CPluginEstimate* pie, CLabels* labels=NULL);
42 
52  CPluginEstimate *pie, CLabels* labels=NULL);
53 
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 
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:
126 
131 
136 
141 
143  int32_t num_params;
145  int32_t num_symbols;
154 };
155 }
156 #endif /* _SALZBERGWORDKERNEL_H__ */

SHOGUN Machine Learning Toolbox - Documentation