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
00022 class CWeightedCommWordStringKernel: public CCommWordStringKernel
00023 {
00024 public:
00031 CWeightedCommWordStringKernel(INT size, bool use_sign,
00032 ENormalizationType normalization_=FULL_NORMALIZATION);
00033
00042 CWeightedCommWordStringKernel(
00043 CStringFeatures<WORD>* l, CStringFeatures<WORD>* r,
00044 bool use_sign=false,
00045 ENormalizationType normalization_=FULL_NORMALIZATION,
00046 INT size=10);
00047
00048 virtual ~CWeightedCommWordStringKernel();
00049
00056 virtual bool init(CFeatures* l, CFeatures* r);
00057
00059 virtual void cleanup();
00060
00066 virtual DREAL compute_optimized(INT idx);
00067
00073 virtual void add_to_normal(INT idx, DREAL weight);
00074
00076 void merge_normal();
00077
00082 bool set_wd_weights();
00083
00090 bool set_weights(DREAL* w, INT d);
00091
00096 virtual EKernelType get_kernel_type() { return K_WEIGHTEDCOMMWORDSTRING; }
00097
00102 virtual const CHAR* get_name() { return "WeightedCommWordString"; }
00103
00108 inline virtual EFeatureType get_feature_type() { return F_WORD; }
00109
00122 virtual DREAL* compute_scoring(INT max_degree, INT& num_feat,
00123 INT& num_sym, DREAL* target, INT num_suppvec, INT* IDX,
00124 DREAL* alphas, bool do_init=true);
00125
00126 protected:
00133 virtual DREAL compute_helper(INT idx_a, INT idx_b, bool do_sort);
00134
00136 INT degree;
00137
00139 DREAL* weights;
00140 };
00141
00142 #endif