SHOGUN  3.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CommWordStringKernel.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-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__ */

SHOGUN Machine Learning Toolbox - Documentation