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-2008 Soeren Sonnenburg
00008  * Written (W) 1999-2008 Gunnar Raetsch
00009  * Copyright (C) 1999-2008 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 
00047 class CWeightedCommWordStringKernel: public CCommWordStringKernel
00048 {
00049     public:
00055         CWeightedCommWordStringKernel(int32_t size, bool use_sign);
00056 
00064         CWeightedCommWordStringKernel(
00065             CStringFeatures<uint16_t>* l, CStringFeatures<uint16_t>* r,
00066             bool use_sign=false, int32_t size=10);
00067 
00068         virtual ~CWeightedCommWordStringKernel();
00069 
00076         virtual bool init(CFeatures* l, CFeatures* r);
00077 
00079         virtual void cleanup();
00080 
00086         virtual float64_t compute_optimized(int32_t idx);
00087 
00093         virtual void add_to_normal(int32_t idx, float64_t weight);
00094 
00096         void merge_normal();
00097 
00102         bool set_wd_weights();
00103 
00110         bool set_weights(float64_t* w, int32_t d);
00111 
00116         virtual EKernelType get_kernel_type() { return K_WEIGHTEDCOMMWORDSTRING; }
00117 
00122         virtual const char* get_name() { return "WeightedCommWordString"; }
00123 
00128         inline virtual EFeatureType get_feature_type() { return F_WORD; }
00129 
00142         virtual float64_t* compute_scoring(
00143             int32_t max_degree, int32_t& num_feat, int32_t& num_sym,
00144             float64_t* target, int32_t num_suppvec, int32_t* IDX,
00145             float64_t* alphas, bool do_init=true);
00146 
00147     protected:
00154         virtual float64_t compute_helper(
00155             int32_t idx_a, int32_t idx_b, bool do_sort);
00156 
00158         int32_t degree;
00159 
00161         float64_t* weights;
00162 };
00163 
00164 #endif /* _WEIGHTEDCOMMWORDSTRINGKERNEL_H__ */

SHOGUN Machine Learning Toolbox - Documentation