Feature.cpp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /**
  2. * @file Feature.cpp
  3. * @brief abstraction of a feature
  4. * @author Erik Rodner
  5. * @date 04/21/2008
  6. */
  7. #ifdef NOVISUAL
  8. #include <vislearning/nice_nonvis.h>
  9. #else
  10. #include <vislearning/nice.h>
  11. #endif
  12. #include <iostream>
  13. #include "Feature.h"
  14. #include "FeaturePool.h"
  15. using namespace OBJREC;
  16. using namespace std;
  17. // refactor-nice.pl: check this substitution
  18. // old: using namespace ice;
  19. using namespace NICE;
  20. Feature::Feature()
  21. {
  22. }
  23. Feature::~Feature()
  24. {
  25. }
  26. void Feature::calcFeatureValues ( const Examples & examples,
  27. vector<int> & examples_selection,
  28. FeatureValues & values ) const
  29. {
  30. for ( vector<int>::const_iterator si = examples_selection.begin();
  31. si != examples_selection.end();
  32. si++ )
  33. {
  34. int index = *si;
  35. const pair<int, Example> & p = examples[index];
  36. int classno = p.first;
  37. const Example & ce = p.second;
  38. double value = val ( &ce );
  39. values.insert ( quadruplet<double, int, int,double> ( value, classno, index, ce.weight ) );
  40. }
  41. }
  42. void Feature::calcFeatureValues ( const Examples & examples,
  43. vector<int> & examples_selection,
  44. FeatureValuesUnsorted & values ) const
  45. {
  46. for ( vector<int>::const_iterator si = examples_selection.begin();
  47. si != examples_selection.end();
  48. si++ )
  49. {
  50. int index = *si;
  51. const pair<int, Example> & p = examples[index];
  52. int classno = p.first;
  53. const Example & ce = p.second;
  54. double value = val ( &ce );
  55. values.push_back ( quadruplet<double, int, int, double> ( value, classno, index, ce.weight ) );
  56. }
  57. }