InferenceMethod.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  * Copyright (C) 2012 Jacob Walker
00008  */
00009 
00010 #ifndef CINFERENCEMETHOD_H_
00011 #define CINFERENCEMETHOD_H_
00012 #ifdef HAVE_EIGEN3
00013 #include <shogun/kernel/Kernel.h>
00014 #include <shogun/base/SGObject.h>
00015 #include <shogun/features/DotFeatures.h>
00016 #include <shogun/labels/Labels.h>
00017 #include <shogun/regression/gp/LikelihoodModel.h>
00018 #include <shogun/regression/gp/MeanFunction.h>
00019 #include <shogun/evaluation/DifferentiableFunction.h>
00020 #include <shogun/labels/RegressionLabels.h>
00021 
00022 
00023 namespace shogun
00024 {
00025 
00032 class CInferenceMethod : public CDifferentiableFunction
00033 {
00034   
00035 public:
00036 
00040     CInferenceMethod();
00041 
00049     CInferenceMethod(CKernel* kernel, CFeatures* features,
00050             CMeanFunction* mean, CLabels* labels, CLikelihoodModel* model);
00051 
00053     virtual ~CInferenceMethod();
00054 
00064     virtual float64_t get_negative_marginal_likelihood() = 0;
00065 
00074     virtual CMap<TParameter*, SGVector<float64_t> >
00075         get_marginal_likelihood_derivatives(
00076         CMap<TParameter*, CSGObject*>& para_dict) = 0;
00077 
00087     virtual SGVector<float64_t> get_alpha() = 0;
00088 
00099     virtual SGMatrix<float64_t> get_cholesky() = 0;
00100 
00111     virtual SGVector<float64_t> get_diagonal_vector() = 0;
00112 
00117     virtual void set_features(CFeatures* feat);
00118 
00123     virtual CFeatures* get_features()
00124     {
00125         SG_REF(m_features);
00126         return m_features;
00127     }
00128 
00133     virtual CKernel* get_kernel() { SG_REF(m_kernel); return m_kernel; }
00134 
00139     virtual void set_kernel(CKernel* kern);
00140 
00145     virtual CMeanFunction* get_mean() { SG_REF(m_mean); return m_mean; }
00146 
00151     virtual void set_mean(CMeanFunction* m);
00152 
00157     virtual CLabels* get_labels() { SG_REF(m_labels); return m_labels; }
00158 
00163     virtual void set_labels(CLabels* lab);
00164 
00169     CLikelihoodModel* get_model() {SG_REF(m_model); return m_model; }
00170 
00175     virtual void set_model(CLikelihoodModel* mod);
00176 
00181     virtual void set_scale(float64_t s);
00182 
00187     virtual float64_t get_scale() { return m_scale; }
00188 
00193     virtual void set_latent_features(CFeatures* feat);
00194 
00199     virtual CFeatures* get_latent_features()
00200     {
00201         SG_REF(m_latent_features);
00202         return m_latent_features;
00203     }
00204 
00205 
00206 protected:
00207 
00209     virtual void update_alpha() {}
00210 
00212     virtual void update_chol() {}
00213 
00215     virtual void update_train_kernel() {}
00216 
00218     virtual void update_data_means();
00219 
00220 private:
00221     void init();
00222 
00223 protected:
00224 
00226     CKernel* m_kernel;
00227 
00229     CFeatures* m_features;
00230 
00232     SGMatrix<float64_t> m_feature_matrix;
00233 
00235     SGVector<float64_t> m_data_means;
00236 
00238     SGVector<float64_t> m_label_vector;
00239 
00240 
00242     CLabels* m_labels;
00243 
00245     CMeanFunction* m_mean;
00246 
00248     CFeatures* m_latent_features;
00249 
00259     CLikelihoodModel* m_model;
00260 
00262     SGVector< float64_t > m_alpha;
00263 
00267     SGMatrix<float64_t> m_L;
00268 
00270     float64_t m_scale;
00271 
00273     SGMatrix<float64_t> m_ktrtr;
00274 
00276     SGMatrix<float64_t> m_latent_matrix;
00277 
00278 };
00279 
00280 }
00281 #endif /* HAVE_EIGEN3 */
00282 #endif /* CInferenceMethod_H_ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

SHOGUN Machine Learning Toolbox - Documentation