LaplaceApproximation.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. {
  13. /** @class LaplaceApproximation
  14. * some utility functions for laplace approximation
  15. *
  16. * @author Erik Rodner
  17. */
  18. class LaplaceApproximation
  19. {
  20. protected:
  21. /** optimization settings */
  22. uint maxiterations;
  23. double minimumDelta;
  24. bool verbose;
  25. /** useful variables */
  26. NICE::Vector mode;
  27. NICE::Vector hessianW;
  28. NICE::Vector gradientL;
  29. NICE::Matrix cholB;
  30. NICE::Vector a;
  31. double objective;
  32. double noiseTerm;
  33. void updateCache ( const NICE::Matrix & kernelMatrix, const NICE::Vector & y, const LikelihoodFunction *likelihoodFunction );
  34. public:
  35. /** use standard settings */
  36. LaplaceApproximation();
  37. /** simple constructor using config values for numerical details */
  38. LaplaceApproximation ( const NICE::Config *conf, const std::string & section = "LaplaceApproximation" );
  39. /** simple destructor */
  40. virtual ~LaplaceApproximation();
  41. void approximate ( KernelData *kernelData, const NICE::Vector & y,
  42. const LikelihoodFunction *likelihoodFunction );
  43. double predict ( const NICE::Vector & kernelVector, double kernelSelf, const NICE::Vector & y,
  44. const LikelihoodFunction *likelihoodFunction ) const;
  45. const NICE::Vector & getMode () const
  46. {
  47. return mode;
  48. };
  49. const NICE::Vector & getHessian () const
  50. {
  51. return hessianW;
  52. };
  53. const NICE::Vector & getGradient () const
  54. {
  55. return gradientL;
  56. };
  57. const NICE::Vector & getAVector () const
  58. {
  59. return a;
  60. };
  61. const NICE::Matrix & getCholeskyB () const
  62. {
  63. return cholB;
  64. };
  65. double getObjective () const
  66. {
  67. return objective;
  68. };
  69. };
  70. }
  71. #endif