WeightedCommWordStringKernel.h
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 class CCommWordStringKernel;
00020
00048 class CWeightedCommWordStringKernel: public CCommWordStringKernel
00049 {
00050 public:
00056 CWeightedCommWordStringKernel(int32_t size, bool use_sign);
00057
00065 CWeightedCommWordStringKernel(
00066 CStringFeatures<uint16_t>* l, CStringFeatures<uint16_t>* r,
00067 bool use_sign=false, int32_t size=10);
00068
00069 virtual ~CWeightedCommWordStringKernel();
00070
00077 virtual bool init(CFeatures* l, CFeatures* r);
00078
00080 virtual void cleanup();
00081
00087 virtual float64_t compute_optimized(int32_t idx);
00088
00094 virtual void add_to_normal(int32_t idx, float64_t weight);
00095
00097 void merge_normal();
00098
00103 bool set_wd_weights();
00104
00111 bool set_weights(float64_t* w, int32_t d);
00112
00117 virtual EKernelType get_kernel_type() { return K_WEIGHTEDCOMMWORDSTRING; }
00118
00123 virtual const char* get_name() const { return "WeightedCommWordString"; }
00124
00129 inline virtual EFeatureType get_feature_type() { return F_WORD; }
00130
00143 virtual float64_t* compute_scoring(
00144 int32_t max_degree, int32_t& num_feat, int32_t& num_sym,
00145 float64_t* target, int32_t num_suppvec, int32_t* IDX,
00146 float64_t* alphas, bool do_init=true);
00147
00148 protected:
00155 virtual float64_t compute_helper(
00156 int32_t idx_a, int32_t idx_b, bool do_sort);
00157
00159 int32_t degree;
00160
00162 float64_t* weights;
00163 };
00164
00165 #endif