LinearWordKernel.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  * Copyright (C) 1999-2008 Fraunhofer Institute FIRST and Max-Planck-Society
00009  */
00010 
00011 #ifndef _LINEARWORDKERNEL_H___
00012 #define _LINEARWORDKERNEL_H___
00013 
00014 #include "lib/common.h"
00015 #include "kernel/SimpleKernel.h"
00016 #include "features/WordFeatures.h"
00017 
00019 class CLinearWordKernel: public CSimpleKernel<WORD>
00020 {
00021     public:
00028         CLinearWordKernel(INT size,
00029             bool do_rescale=true, DREAL scale=1.);
00030 
00038         CLinearWordKernel(CWordFeatures* l, CWordFeatures* r,
00039             bool do_rescale=true, DREAL scale=1.);
00040 
00041         virtual ~CLinearWordKernel();
00042 
00049         virtual bool init(CFeatures* l, CFeatures* r);
00050 
00052         virtual void cleanup();
00053 
00059         virtual bool load_init(FILE* src);
00060 
00066         virtual bool save_init(FILE* dest);
00067 
00072         virtual EKernelType get_kernel_type() { return K_LINEAR; }
00073 
00078         virtual const CHAR* get_name() { return "Linear"; }
00079 
00087         virtual bool init_optimization(INT num_suppvec, INT* sv_idx, DREAL* alphas);
00088 
00093         virtual bool delete_optimization();
00094 
00100         virtual DREAL compute_optimized(INT idx);
00101 
00103         virtual void clear_normal();
00104 
00110         virtual void add_to_normal(INT idx, DREAL weight);
00111 
00112     protected:
00121         virtual DREAL compute(INT idx_a, INT idx_b);
00122 
00124         virtual void init_rescale();
00125 
00126     protected:
00128         double scale;
00130         bool do_rescale;
00132         bool initialized;
00134         double* normal;
00135 };
00136 
00137 #endif /* _LINEARWORDKERNEL_H__ */

SHOGUN Machine Learning Toolbox - Documentation