LaplaceApproximation.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /**
  2. * @file LaplaceApproximation.h
  3. * @author Erik Rodner
  4. * @date 02/17/2010
  5. */
  6. #ifndef _NICE_OBJREC_LAPLACEAPPROXIMATIONINCLUDE
  7. #define _NICE_OBJREC_LAPLACEAPPROXIMATIONINCLUDE
  8. #include "core/basics/Config.h"
  9. #include "vislearning/classifier/kernelclassifier/LikelihoodFunction.h"
  10. #include "vislearning/math/kernels/KernelData.h"
  11. namespace OBJREC {
  12. /** @class LaplaceApproximation
  13. * some utility functions for laplace approximation
  14. *
  15. * @author Erik Rodner
  16. */
  17. class LaplaceApproximation
  18. {
  19. protected:
  20. /** optimization settings */
  21. uint maxiterations;
  22. double minimumDelta;
  23. bool verbose;
  24. /** useful variables */
  25. NICE::Vector mode;
  26. NICE::Vector hessianW;
  27. NICE::Vector gradientL;
  28. NICE::Matrix cholB;
  29. NICE::Vector a;
  30. double objective;
  31. double noiseTerm;
  32. void updateCache ( const NICE::Matrix & kernelMatrix, const NICE::Vector & y, const LikelihoodFunction *likelihoodFunction );
  33. public:
  34. /** use standard settings */
  35. LaplaceApproximation();
  36. /** simple constructor using config values for numerical details */
  37. LaplaceApproximation( const NICE::Config *conf, const std::string & section = "LaplaceApproximation" );
  38. /** simple destructor */
  39. virtual ~LaplaceApproximation();
  40. void approximate ( KernelData *kernelData, const NICE::Vector & y,
  41. const LikelihoodFunction *likelihoodFunction );
  42. double predict ( const NICE::Vector & kernelVector, double kernelSelf, const NICE::Vector & y,
  43. const LikelihoodFunction *likelihoodFunction ) const;
  44. const NICE::Vector & getMode () const { return mode; };
  45. const NICE::Vector & getHessian () const { return hessianW; };
  46. const NICE::Vector & getGradient () const { return gradientL; };
  47. const NICE::Vector & getAVector () const { return a; };
  48. const NICE::Matrix & getCholeskyB () const { return cholB; };
  49. double getObjective () const { return objective; };
  50. };
  51. }
  52. #endif