HistogramWordKernel.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 _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 
00021 class CHistogramWordKernel: public CStringKernel<WORD>
00022 {
00023     public:
00029         CHistogramWordKernel(INT size, CPluginEstimate* pie);
00030 
00037         CHistogramWordKernel(
00038             CStringFeatures<WORD>* l, CStringFeatures<WORD>* r,
00039             CPluginEstimate* pie);
00040 
00041         virtual ~CHistogramWordKernel();
00042 
00049         virtual bool init(CFeatures* l, CFeatures* r);
00050 
00052         virtual void cleanup();
00053 
00059         bool load_init(FILE* src);
00060 
00066         bool save_init(FILE* dest);
00067 
00072         virtual EKernelType get_kernel_type() { return K_HISTOGRAM; }
00073 
00078         virtual const CHAR* get_name() { return "Histogram" ; } ;
00079 
00080     protected:
00089         DREAL compute(INT idx_a, INT idx_b);
00090 
00097         inline INT compute_index(INT position, WORD symbol)
00098         {
00099             return position*num_symbols+symbol+1;
00100         }
00101 
00102     protected:
00104         CPluginEstimate* estimate;
00105 
00107         DREAL* mean;
00109         DREAL* variance;
00110 
00112         DREAL* sqrtdiag_lhs;
00114         DREAL* sqrtdiag_rhs;
00115 
00117         DREAL* ld_mean_lhs;
00119         DREAL* ld_mean_rhs;
00120 
00122         DREAL* plo_lhs;
00124         DREAL* plo_rhs;
00125 
00127         INT num_params;
00129         INT num_params2;
00131         INT num_symbols;
00133         DREAL sum_m2_s2;
00134 
00136         bool initialized;
00137 };
00138 
00139 #endif /* _HISTOGRAMWORDKERNEL_H__ */

SHOGUN Machine Learning Toolbox - Documentation