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 <shogun/lib/common.h>
00016 #include <shogun/mathematics/Math.h>
00017 #include <shogun/kernel/CommWordStringKernel.h>
00018
00019 namespace shogun
00020 {
00021 class CCommWordStringKernel;
00022
00050 class CWeightedCommWordStringKernel: public CCommWordStringKernel
00051 {
00052 public:
00054 CWeightedCommWordStringKernel();
00055
00061 CWeightedCommWordStringKernel(int32_t size, bool use_sign);
00062
00070 CWeightedCommWordStringKernel(
00071 CStringFeatures<uint16_t>* l, CStringFeatures<uint16_t>* r,
00072 bool use_sign=false, int32_t size=10);
00073
00074 virtual ~CWeightedCommWordStringKernel();
00075
00082 virtual bool init(CFeatures* l, CFeatures* r);
00083
00085 virtual void cleanup();
00086
00092 virtual float64_t compute_optimized(int32_t idx);
00093
00099 virtual void add_to_normal(int32_t idx, float64_t weight);
00100
00102 void merge_normal();
00103
00108 bool set_wd_weights();
00109
00116 bool set_weights(float64_t* w, int32_t d);
00117
00122 virtual EKernelType get_kernel_type() { return K_WEIGHTEDCOMMWORDSTRING; }
00123
00128 virtual const char* get_name() const { return "WeightedCommWordStringKernel"; }
00129
00134 inline virtual EFeatureType get_feature_type() { return F_WORD; }
00135
00148 virtual float64_t* compute_scoring(
00149 int32_t max_degree, int32_t& num_feat, int32_t& num_sym,
00150 float64_t* target, int32_t num_suppvec, int32_t* IDX,
00151 float64_t* alphas, bool do_init=true);
00152
00153 protected:
00160 virtual float64_t compute_helper(
00161 int32_t idx_a, int32_t idx_b, bool do_sort);
00162
00163 private:
00164 void init();
00165
00166 protected:
00168 int32_t degree;
00169
00171 float64_t* weights;
00172 };
00173 }
00174 #endif