FPCnone.cpp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #include "objrec-froehlichexp/classifier/FPCnone.h"
  2. #include <iostream>
  3. using namespace OBJREC;
  4. using namespace std;
  5. using namespace NICE;
  6. FPCnone::FPCnone ()
  7. {
  8. }
  9. FPCnone::FPCnone( const Config *_conf, string section )
  10. {
  11. conf = _conf;
  12. }
  13. FPCnone::~FPCnone()
  14. {
  15. //clean up
  16. }
  17. ClassificationResult FPCnone::classify ( Example & pce )
  18. {
  19. FullVector overall_distribution(maxClassNo+1);
  20. overall_distribution[maxClassNo] = 0.0;
  21. double maxp = -numeric_limits<double>::max();
  22. int classno = 0;
  23. double sum = 0.0;
  24. for(int i = 0; i < maxClassNo; i++)
  25. {
  26. overall_distribution[i] = (*pce.vec)[i];
  27. sum += overall_distribution[i];
  28. if(maxp < overall_distribution[i])
  29. {
  30. classno = i;
  31. maxp = overall_distribution[i];
  32. }
  33. }
  34. /*for(int i = 0; i < maxClassNo; i++)
  35. {
  36. overall_distribution[i] /= sum;
  37. }*/
  38. cout << "Klasse: " << classno << " prob: " << overall_distribution[classno] << endl;
  39. return ClassificationResult ( classno, overall_distribution );
  40. }
  41. void FPCnone::train ( FeaturePool & _fp, Examples & examples )
  42. {
  43. fp = FeaturePool(_fp);
  44. }
  45. void FPCnone::restore (istream & is, int format)
  46. {
  47. }
  48. void FPCnone::store (ostream & os, int format) const
  49. {
  50. }
  51. void FPCnone::clear ()
  52. {
  53. }
  54. FeaturePoolClassifier *FPCnone::clone () const
  55. {
  56. FPCnone *o = new FPCnone ( conf, "non" );
  57. o->maxClassNo = maxClassNo;
  58. return o;
  59. }
  60. void FPCnone::setComplexity ( int size )
  61. {
  62. cerr << "FPCnone: no complexity to set" << endl;
  63. }