WeightedCommWordStringKernel.h

Go to the documentation of this file.
00001 /*
00002  * This program is free software; you can redistribute it and/or modify
00003  * it under the terms of the GNU General Public License as published by
00004  * the Free Software Foundation; either version 3 of the License, or
00005  * (at your option) any later version.
00006  *
00007  * Written (W) 1999-2009 Soeren Sonnenburg
00008  * Written (W) 1999-2008 Gunnar Raetsch
00009  * Copyright (C) 1999-2009 Fraunhofer Institute FIRST and Max-Planck-Society
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 /* _WEIGHTEDCOMMWORDSTRINGKERNEL_H__ */

SHOGUN Machine Learning Toolbox - Documentation