HistogramWordStringKernel.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 _HISTOGRAMWORDKERNEL_H___
00013 #define _HISTOGRAMWORDKERNEL_H___
00014 
00015 #include "lib/common.h"
00016 #include "kernel/StringKernel.h"
00017 #include "classifier/PluginEstimate.h"
00018 #include "features/StringFeatures.h"
00019 
00020 namespace shogun
00021 {
00022     class CPluginEstimate;
00023     template <class T> class CStringFeatures;
00026 class CHistogramWordStringKernel: public CStringKernel<uint16_t>
00027 {
00028     public:
00030         CHistogramWordStringKernel();
00031 
00037         CHistogramWordStringKernel(int32_t size, CPluginEstimate* pie);
00038 
00045         CHistogramWordStringKernel(
00046             CStringFeatures<uint16_t>* l, CStringFeatures<uint16_t>* r,
00047             CPluginEstimate* pie);
00048 
00049         virtual ~CHistogramWordStringKernel();
00050 
00057         virtual bool init(CFeatures* l, CFeatures* r);
00058 
00060         virtual void cleanup();
00061 
00066         virtual EKernelType get_kernel_type() { return K_HISTOGRAM; }
00067 
00072         virtual const char* get_name() const { return "Histogram" ; }
00073 
00074     protected:
00083         float64_t compute(int32_t idx_a, int32_t idx_b);
00084 
00091         inline int32_t compute_index(int32_t position, uint16_t symbol)
00092         {
00093             return position*num_symbols+symbol+1;
00094         }
00095 
00096     private:
00097         void init();
00098 
00099     protected:
00101         CPluginEstimate* estimate;
00102 
00104         float64_t* mean;
00106         float64_t* variance;
00107 
00109         float64_t* sqrtdiag_lhs;
00111         float64_t* sqrtdiag_rhs;
00112 
00114         float64_t* ld_mean_lhs;
00116         float64_t* ld_mean_rhs;
00117 
00119         float64_t* plo_lhs;
00121         float64_t* plo_rhs;
00122 
00124         int32_t num_params;
00126         int32_t num_params2;
00128         int32_t num_symbols;
00130         float64_t sum_m2_s2;
00131 
00133         bool initialized;
00134 };
00135 }
00136 #endif /* _HISTOGRAMWORDKERNEL_H__ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

SHOGUN Machine Learning Toolbox - Documentation