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 namespace shogun
00020 {
00021 class CCommWordStringKernel;
00022 
00050 class CWeightedCommWordStringKernel: public CCommWordStringKernel
00051 {
00052     public:
00058         CWeightedCommWordStringKernel(int32_t size, bool use_sign);
00059 
00067         CWeightedCommWordStringKernel(
00068             CStringFeatures<uint16_t>* l, CStringFeatures<uint16_t>* r,
00069             bool use_sign=false, int32_t size=10);
00070 
00071         virtual ~CWeightedCommWordStringKernel();
00072 
00079         virtual bool init(CFeatures* l, CFeatures* r);
00080 
00082         virtual void cleanup();
00083 
00089         virtual float64_t compute_optimized(int32_t idx);
00090 
00096         virtual void add_to_normal(int32_t idx, float64_t weight);
00097 
00099         void merge_normal();
00100 
00105         bool set_wd_weights();
00106 
00113         bool set_weights(float64_t* w, int32_t d);
00114 
00119         virtual EKernelType get_kernel_type() { return K_WEIGHTEDCOMMWORDSTRING; }
00120 
00125         virtual const char* get_name() const { return "WeightedCommWordString"; }
00126 
00131         inline virtual EFeatureType get_feature_type() { return F_WORD; }
00132 
00145         virtual float64_t* compute_scoring(
00146             int32_t max_degree, int32_t& num_feat, int32_t& num_sym,
00147             float64_t* target, int32_t num_suppvec, int32_t* IDX,
00148             float64_t* alphas, bool do_init=true);
00149 
00150     protected:
00157         virtual float64_t compute_helper(
00158             int32_t idx_a, int32_t idx_b, bool do_sort);
00159 
00161         int32_t degree;
00162 
00164         float64_t* weights;
00165 };
00166 }
00167 #endif /* _WEIGHTEDCOMMWORDSTRINGKERNEL_H__ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

SHOGUN Machine Learning Toolbox - Documentation