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 
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 /* _WEIGHTEDCOMMWORDSTRINGKERNEL_H__ */

SHOGUN Machine Learning Toolbox - Documentation