RegKNN.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /**
  2. * @file RegKNN.h
  3. * @brief Implementation of k-Nearest-Neighbor algorithm for regression purposes
  4. * @author Frank Prüfer
  5. * @date 08/29/2013
  6. */
  7. #ifndef REGKNNINCLUDE
  8. #define REGKNNINCLUDE
  9. #include "core/vector/VectorT.h"
  10. #include "core/vector/VVector.h"
  11. #include "core/vector/MatrixT.h"
  12. #include "core/basics/Config.h"
  13. #include <core/vector/Distance.h>
  14. #include "vislearning/regression/regressionbase/RegressionAlgorithm.h"
  15. namespace OBJREC
  16. {
  17. class RegKNN : public RegressionAlgorithm
  18. {
  19. protected:
  20. int K;
  21. /** set of data points */
  22. NICE::VVector dataSet;
  23. /** set of responses according to dataset */
  24. NICE::Vector labelSet;
  25. /** used distance function */
  26. NICE::VectorDistance<double> *distancefunc;
  27. public:
  28. /** simple constructor */
  29. RegKNN( const NICE::Config *conf, NICE::VectorDistance<double> *distancefunc = NULL );
  30. /** simple destructor */
  31. virtual ~RegKNN();
  32. /** predict response using simple vector */
  33. double predict ( const NICE::Vector & x );
  34. /** teach whole set at once */
  35. void teach ( const NICE::VVector & dataSet, const NICE::Vector & labelSet );
  36. // /** teach one data point at a time */
  37. // void teach ( const NICE::Vector & x, const double & y );
  38. };
  39. } //namespace
  40. #endif