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: 00034 CHistogramWordStringKernel(int32_t size, CPluginEstimate* pie); 00035 00042 CHistogramWordStringKernel( 00043 CStringFeatures<uint16_t>* l, CStringFeatures<uint16_t>* r, 00044 CPluginEstimate* pie); 00045 00046 virtual ~CHistogramWordStringKernel(); 00047 00054 virtual bool init(CFeatures* l, CFeatures* r); 00055 00057 virtual void cleanup(); 00058 00063 virtual EKernelType get_kernel_type() { return K_HISTOGRAM; } 00064 00069 virtual const char* get_name() const { return "Histogram" ; } 00070 00071 protected: 00080 float64_t compute(int32_t idx_a, int32_t idx_b); 00081 00088 inline int32_t compute_index(int32_t position, uint16_t symbol) 00089 { 00090 return position*num_symbols+symbol+1; 00091 } 00092 00093 protected: 00095 CPluginEstimate* estimate; 00096 00098 float64_t* mean; 00100 float64_t* variance; 00101 00103 float64_t* sqrtdiag_lhs; 00105 float64_t* sqrtdiag_rhs; 00106 00108 float64_t* ld_mean_lhs; 00110 float64_t* ld_mean_rhs; 00111 00113 float64_t* plo_lhs; 00115 float64_t* plo_rhs; 00116 00118 int32_t num_params; 00120 int32_t num_params2; 00122 int32_t num_symbols; 00124 float64_t sum_m2_s2; 00125 00127 bool initialized; 00128 }; 00129 } 00130 #endif /* _HISTOGRAMWORDKERNEL_H__ */