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/string/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
00115 bool set_weights(SGVector<float64_t> weights);
00116
00121 virtual EKernelType get_kernel_type() { return K_WEIGHTEDCOMMWORDSTRING; }
00122
00127 virtual const char* get_name() const { return "WeightedCommWordStringKernel"; }
00128
00133 virtual EFeatureType get_feature_type() { return F_WORD; }
00134
00147 virtual float64_t* compute_scoring(
00148 int32_t max_degree, int32_t& num_feat, int32_t& num_sym,
00149 float64_t* target, int32_t num_suppvec, int32_t* IDX,
00150 float64_t* alphas, bool do_init=true);
00151
00152 protected:
00159 virtual float64_t compute_helper(
00160 int32_t idx_a, int32_t idx_b, bool do_sort);
00161
00162 private:
00163 void init();
00164
00165 protected:
00167 int32_t degree;
00168
00170 float64_t* weights;
00171 };
00172 }
00173 #endif