rf.hpp

00001 //
00002 //  Copyright (c) 2005-2007
00003 //  James N Knight
00004 //
00005 //  Permission to use, copy, modify, distribute and sell this software
00006 //  and its documentation for any purpose is hereby granted without fee,
00007 //  provided that the above copyright notice appear in all copies and
00008 //  that both that copyright notice and this permission notice appear
00009 //  in supporting documentation.  The authors make no representations
00010 //  about the suitability of this software for any purpose.
00011 //  It is provided "as is" without express or implied warranty.
00012 //
00013 //  
00014 // See http://homepages.inf.ed.ac.uk/svijayak/publications/vijayakumar-NeuCom2005.pdf
00015 // for the original publication of this algorithm.
00016 
00017 
00018 
00019 #ifndef RF_HPP
00020 #define RF_HPP
00021 
00022 #include <math.h>
00023 
00024 #include <boost/numeric/ublas/vector_expression.hpp>
00025 #include <boost/numeric/ublas/io.hpp>
00026 #include <boost/program_options.hpp>
00027 
00028 #include <fstream>
00029 
00030 #include "types.hpp"
00031 #include "model.hpp"
00032 
00038 class RF {
00039 protected:
00040 
00049     
00053     Types::RParam d_def;
00054 
00059     Types::RParam lambda;
00060 
00064     Types::RParam gamma;
00065 
00069     Types::RParam alpha_init;
00070 
00074     bool meta;
00075 
00079     Types::RValue meta_alpha;
00080 
00082     
00083 
00092     
00094     Types::vector center;
00095 
00097     Model localModel;
00098     
00100 
00101     
00110     
00112     Types::RValue W;
00113 
00114     Types::vector a_H, a_G;
00115     Types::RValue a_E;
00116 
00118     Types::RValue a_pk, sigma;
00119 
00120     Types::RValue e_2;
00121 
00123 
00125     Types::vector z;
00126 
00127     // temp variables, this isn't terribly safe, but its saves having to reallocate
00128     // the damn things every time they're needed
00129     mutable Types::vector temp2, q, H_temp;
00130 
00131 public:
00132 
00134     RF();
00135 
00141     RF(Types::Input c);
00142 
00146     RF(Types::Input c, const boost::program_options::variables_map& vm);
00147 
00148 
00155     virtual Types::RValue getActivation(Types::Input x) const = 0;
00156 
00162     inline Types::OutputT predict(Types::Input x) const { return localModel.predict(x); };
00163 
00169     Types::OutputT confidence(Types::Input x) const;
00170 
00171 
00177     inline bool trustworthy() const { return localModel.trustworthy(); };
00178 
00179 
00190     virtual Types::RValue learn(Types::Input x, Types::Output y, Types::RValueP w) = 0;
00191 
00195     friend std::ostream& operator<<(std::ostream& out, const RF& rf);
00196 
00197 };
00198 
00199 #endif

Generated on Fri Jul 27 00:24:01 2007 for LWPR by  doxygen 1.5.1