rf.cpp

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 #include <boost/numeric/ublas/vector.hpp>
00020 #include <boost/numeric/ublas/matrix.hpp>
00021 #include <boost/numeric/ublas/matrix_expression.hpp>
00022 #include <boost/numeric/ublas/triangular.hpp>
00023 #include <boost/numeric/ublas/io.hpp>
00024 
00025 #include <algorithm>
00026 
00027 #include <math.h>
00028 
00029 #include "rf.hpp"
00030 
00031 RF::RF()
00032 {
00033 
00034 }
00035 
00036 RF::RF(Types::Input c) : 
00037     center(c), 
00038     z(c.size()),
00039     temp2(c.size()),
00040     localModel(c.size()),
00041     a_H(2),
00042     a_G(2),
00043     a_E(0), 
00044     H_temp(2)
00045 {
00046     d_def = 25;
00047     lambda = .999;
00048     gamma = 1e-6;
00049     alpha_init = 250;
00050     meta = false;
00051 
00052     W = 1e-10;
00053     e_2 = 0;
00054 
00055     a_H.clear();
00056     a_G.clear();
00057 
00058 }
00059 
00060 RF::RF(Types::Input c, const boost::program_options::variables_map& vm) : 
00061     center(c), 
00062     z(c.size()),
00063     temp2(c.size()),
00064     localModel(c.size(),vm),
00065     a_H(2),
00066     a_G(2),
00067     a_E(0), 
00068     H_temp(2)
00069 {
00070 
00071     d_def = vm["d_def"].as<Types::RParam>();
00072     lambda = vm["lambda"].as<Types::RParam>();
00073     gamma = vm["gamma"].as<Types::RParam>();
00074     alpha_init = vm["alpha"].as<Types::RParam>();
00075     meta = vm["meta"].as<bool>();
00076 
00077     if(meta){
00078         meta_alpha = vm["theta"].as<Types::RParam>();
00079     }
00080         
00081     W = 1e-10;
00082     e_2 = 0;
00083 
00084     a_H.clear();
00085     a_G.clear();
00086 }
00087 
00088 Types::OutputT RF::confidence(Types::Input x) const {
00089     
00090     Types::vector z;
00091     localModel.project(x,z);
00092 
00093     Types::Input derivative = localModel.check_derivatives();
00094     q = element_div(element_prod(z,derivative),localModel.get_a_zz());
00095 
00096     return a_pk*(1 + getActivation(x) * ublas::prec_inner_prod(z,q));
00097 
00098 
00099 }

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