Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef _WEIGHTEDCOMMWORDSTRINGKERNEL_H___
00013 #define _WEIGHTEDCOMMWORDSTRINGKERNEL_H___
00014
00015 #include "lib/common.h"
00016 #include "lib/Mathematics.h"
00017 #include "kernel/CommWordStringKernel.h"
00018
00019 namespace shogun
00020 {
00021 class CCommWordStringKernel;
00022
00050 class CWeightedCommWordStringKernel: public CCommWordStringKernel
00051 {
00052 public:
00058 CWeightedCommWordStringKernel(int32_t size, bool use_sign);
00059
00067 CWeightedCommWordStringKernel(
00068 CStringFeatures<uint16_t>* l, CStringFeatures<uint16_t>* r,
00069 bool use_sign=false, int32_t size=10);
00070
00071 virtual ~CWeightedCommWordStringKernel();
00072
00079 virtual bool init(CFeatures* l, CFeatures* r);
00080
00082 virtual void cleanup();
00083
00089 virtual float64_t compute_optimized(int32_t idx);
00090
00096 virtual void add_to_normal(int32_t idx, float64_t weight);
00097
00099 void merge_normal();
00100
00105 bool set_wd_weights();
00106
00113 bool set_weights(float64_t* w, int32_t d);
00114
00119 virtual EKernelType get_kernel_type() { return K_WEIGHTEDCOMMWORDSTRING; }
00120
00125 virtual const char* get_name() const { return "WeightedCommWordString"; }
00126
00131 inline virtual EFeatureType get_feature_type() { return F_WORD; }
00132
00145 virtual float64_t* compute_scoring(
00146 int32_t max_degree, int32_t& num_feat, int32_t& num_sym,
00147 float64_t* target, int32_t num_suppvec, int32_t* IDX,
00148 float64_t* alphas, bool do_init=true);
00149
00150 protected:
00157 virtual float64_t compute_helper(
00158 int32_t idx_a, int32_t idx_b, bool do_sort);
00159
00161 int32_t degree;
00162
00164 float64_t* weights;
00165 };
00166 }
00167 #endif