FPCnone.cpp 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. #include "semseg/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. }