FPCnone.cpp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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+1; 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. if(classno > 12)
  40. {
  41. cout << "failure" << endl;
  42. }
  43. return ClassificationResult ( classno, overall_distribution );
  44. }
  45. void FPCnone::train ( FeaturePool & _fp, Examples & examples )
  46. {
  47. fp = FeaturePool(_fp);
  48. }
  49. void FPCnone::restore (istream & is, int format)
  50. {
  51. }
  52. void FPCnone::store (ostream & os, int format) const
  53. {
  54. }
  55. void FPCnone::clear ()
  56. {
  57. }
  58. FeaturePoolClassifier *FPCnone::clone () const
  59. {
  60. FPCnone *o = new FPCnone ( conf, "non" );
  61. o->maxClassNo = maxClassNo;
  62. return o;
  63. }
  64. void FPCnone::setComplexity ( int size )
  65. {
  66. cerr << "FPCnone: no complexity to set" << endl;
  67. }