KCGPRegOneVsAll.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /**
  2. * @file KCGPRegOneVsAll.h
  3. * @author Erik Rodner
  4. * @date 12/10/2009
  5. */
  6. #ifndef _NICE_OBJREC_KCGPREGONEVSALLINCLUDE
  7. #define _NICE_OBJREC_KCGPREGONEVSALLINCLUDE
  8. #include "vislearning/classifier/classifierbase/KernelClassifier.h"
  9. #include "vislearning/regression/gpregression/RegGaussianProcess.h"
  10. #include "vislearning/math/kernels/TraceApproximation.h"
  11. #include "vislearning/regression/gpregression/modelselcrit/genericGPModelSelection.h"
  12. #include <vector>
  13. namespace OBJREC {
  14. #undef ROADWORKS
  15. #define ROADWORKS fthrow(Exception, "Persistent interface not implemented!");
  16. /** @class KCGPRegOneVsAll
  17. * One vs. All GP regression classifier with joint optimization
  18. * of kernel parameters
  19. *
  20. * @author Erik Rodner
  21. */
  22. class KCGPRegOneVsAll : public KernelClassifier
  23. {
  24. protected:
  25. /** set of classifiers with the corresponding class */
  26. std::vector< std::pair<int, RegGaussianProcess *> > classifiers;
  27. /** clone from prototype to generate new classifiers */
  28. const RegGaussianProcess *prototype;
  29. /** whether to optimize hyper-parameters */
  30. bool optimizeParameters;
  31. /** tell us something about what you are doing */
  32. bool verbose;
  33. /** maximum number of iterations of the hyper-parameter estimation */
  34. int maxIterations;
  35. TraceApproximation *traceApproximation;
  36. GPMSCLooLikelihoodRegression *modelselcrit;
  37. /** use the hyperparameters which lead to the best leave-one-out criterion */
  38. bool useLooParameters;
  39. /** whether to invest some computation time to estimate the uncertainty of the prediction */
  40. bool computeUncertainty;
  41. /** for computing uncertainties we need the cholesky decomposition of the kernel matrix */
  42. NICE::Matrix choleskyMatrix;
  43. /** whether to calibrate the probabilities using uncertainty estimates */
  44. bool calibrateProbabilities;
  45. /** how many samples should we draw to estimate the probabilities */
  46. uint numSamplesCalibration;
  47. public:
  48. /** simplest constructor */
  49. KCGPRegOneVsAll(){};
  50. /** simple constructor */
  51. KCGPRegOneVsAll( const NICE::Config *conf, Kernel *kernelFunction = NULL, const std::string & section = "KCGPRegOneVsAll" );
  52. /** copy constructor */
  53. KCGPRegOneVsAll( const KCGPRegOneVsAll &vcova );
  54. /** simple destructor */
  55. virtual ~KCGPRegOneVsAll();
  56. /** teach the classifier with a kernel matrix and the corresponding class labels @param y ! */
  57. void teach ( KernelData *kernelData, const NICE::Vector & y );
  58. void teach ( KernelData *kernelData, const std::vector<double> & y );
  59. /** classify an example by using its kernel values with the training set,
  60. be careful with the order in @param kernelVector */
  61. ClassificationResult classifyKernel ( const NICE::Vector & kernelVector, double kernelSelf ) const;
  62. void restore(std::istream&, int);
  63. void store(std::ostream&, int) const;
  64. void clear();
  65. /** clone this object */
  66. virtual KCGPRegOneVsAll *clone(void) const;
  67. };
  68. #undef ROADWORKS
  69. }
  70. #endif