LinearLatentMachine.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) 2012 Viktor Gal
00008  * Copyright (C) 2012 Viktor Gal
00009  */
00010 
00011 #ifndef __LATENTLINEARMACHINE_H__
00012 #define __LATENTLINEARMACHINE_H__
00013 
00014 #include <shogun/lib/common.h>
00015 #include <shogun/machine/LinearMachine.h>
00016 #include <shogun/latent/LatentModel.h>
00017 
00018 namespace shogun
00019 {
00023     class CLinearLatentMachine: public CLinearMachine
00024     {
00025 
00026         public:
00027 
00029             MACHINE_PROBLEM_TYPE(PT_LATENT);
00030 
00032             CLinearLatentMachine();
00033 
00039             CLinearLatentMachine(CLatentModel* model, float64_t C);
00040 
00041             virtual ~CLinearLatentMachine();
00042             
00047             virtual CLatentLabels* apply_latent() = 0;
00048 
00054             virtual CLatentLabels* apply_latent(CFeatures* data);
00055 
00060             virtual const char* get_name() const { return "LinearLatentMachine"; }
00061 
00066             inline void set_epsilon(float64_t eps) { m_epsilon=eps; }
00067 
00072             inline float64_t get_epsilon() { return m_epsilon; }
00073 
00078             inline void set_C(float64_t c)
00079             {
00080                 m_C=c;
00081             }
00082 
00087             inline float64_t get_C() { return m_C; }
00088 
00093             inline void set_max_iterations(int32_t iter) { m_max_iter = iter; }
00094 
00099             inline int32_t get_max_iterations() { return m_max_iter; }
00100 
00105             void set_model(CLatentModel* latent_model);
00106 
00107         protected:
00108             virtual bool train_machine(CFeatures* data=NULL);
00109 
00116             virtual float64_t do_inner_loop(float64_t cooling_eps)=0;
00117 
00118             virtual bool train_require_labels() const { return false; }
00119 
00120         protected:
00122             CLatentModel* m_model;
00124             float64_t m_C;
00126             float64_t m_epsilon;
00128             int32_t m_max_iter;
00129 
00130             int32_t m_cur_iter;
00131 
00132         private:
00134             void init();
00135     };
00136 }
00137 
00138 #endif /* __LATENTLINEARMACHINE_H__ */
00139 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

SHOGUN Machine Learning Toolbox - Documentation