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 
00022 class CHistogramWordStringKernel: public CStringKernel<uint16_t>
00023 {
00024     public:
00030         CHistogramWordStringKernel(int32_t size, CPluginEstimate* pie);
00031 
00038         CHistogramWordStringKernel(
00039             CStringFeatures<uint16_t>* l, CStringFeatures<uint16_t>* r,
00040             CPluginEstimate* pie);
00041 
00042         virtual ~CHistogramWordStringKernel();
00043 
00050         virtual bool init(CFeatures* l, CFeatures* r);
00051 
00053         virtual void cleanup();
00054 
00060         bool load_init(FILE* src);
00061 
00067         bool save_init(FILE* dest);
00068 
00073         virtual EKernelType get_kernel_type() { return K_HISTOGRAM; }
00074 
00079         virtual const char* get_name() const { return "Histogram" ; }
00080 
00081     protected:
00090         float64_t compute(int32_t idx_a, int32_t idx_b);
00091 
00098         inline int32_t compute_index(int32_t position, uint16_t symbol)
00099         {
00100             return position*num_symbols+symbol+1;
00101         }
00102 
00103     protected:
00105         CPluginEstimate* estimate;
00106 
00108         float64_t* mean;
00110         float64_t* variance;
00111 
00113         float64_t* sqrtdiag_lhs;
00115         float64_t* sqrtdiag_rhs;
00116 
00118         float64_t* ld_mean_lhs;
00120         float64_t* ld_mean_rhs;
00121 
00123         float64_t* plo_lhs;
00125         float64_t* plo_rhs;
00126 
00128         int32_t num_params;
00130         int32_t num_params2;
00132         int32_t num_symbols;
00134         float64_t sum_m2_s2;
00135 
00137         bool initialized;
00138 };
00139 
00140 #endif /* _HISTOGRAMWORDKERNEL_H__ */

SHOGUN Machine Learning Toolbox - Documentation