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 <shogun/lib/common.h>
00016 #include <shogun/mathematics/Math.h>
00017 #include <shogun/kernel/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 
00116         bool set_weights(float64_t* w, int32_t d);
00117 
00122         virtual EKernelType get_kernel_type() { return K_WEIGHTEDCOMMWORDSTRING; }
00123 
00128         virtual const char* get_name() const { return "WeightedCommWordStringKernel"; }
00129 
00134         inline virtual EFeatureType get_feature_type() { return F_WORD; }
00135 
00148         virtual float64_t* compute_scoring(
00149             int32_t max_degree, int32_t& num_feat, int32_t& num_sym,
00150             float64_t* target, int32_t num_suppvec, int32_t* IDX,
00151             float64_t* alphas, bool do_init=true);
00152 
00153     protected:
00160         virtual float64_t compute_helper(
00161             int32_t idx_a, int32_t idx_b, bool do_sort);
00162 
00163     private:
00164         void init();
00165 
00166     protected:
00168         int32_t degree;
00169 
00171         float64_t* weights;
00172 };
00173 }
00174 #endif /* _WEIGHTEDCOMMWORDSTRINGKERNEL_H__ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

SHOGUN Machine Learning Toolbox - Documentation