///////////////////////////////////////////// // class ResultFold // is part of BooleSuite 1.0 by Bob Marinier, marinier@cs.wisc.edu // see legal.lic for legal info // // Contains all of the result sets for a fold, with related info // Also determines how to vote ///////////////////////////////////////////// #if !defined(_RESULTFOLD_H_) #define _RESULTFOLD_H_ #include "constants.h" #include "typedefs.h" #include "ResultSet.h" #include "AccuracyInfo.h" #include class ResultFold { public: ResultFold() : totalWeight(1.0) { }; //we don't actually need to set this since it shouldn't be used without being set elsewhere RESULTSETSCONT resultFold; AccuracyInfo aInfo; double totalWeight; //the summed weight of all the result sets (so we can normalize) //how this fold will vote bool vote(std::bitset* testExample, const double votePercentForPos, const LearnType learnType) { double numPosVotes=0; //number of votes for saying this example is positive for(RESULTSETSCONT::iterator itResultSet=resultFold.begin(); itResultSet!=resultFold.end(); itResultSet++) { numPosVotes+=(*itResultSet)->vote(testExample, votePercentForPos, learnType); } //vote by simple majority //note we have to normalize due to the weights on the result sets if(numPosVotes/totalWeight >= 0.5 ) { return true; } else { return false; } } void show(const LearnType learnType, const bool showAll=true) { if(showAll) { std::cout << "\nPercent Correct: " << aInfo.percentCorrect << std::flush; std::cout << "\nTP: " << aInfo.truePositives << std::flush; std::cout << "\nFP: " << aInfo.falsePositives << std::flush; std::cout << "\nTN: " << aInfo.trueNegatives << std::flush; std::cout << "\nFN: " << aInfo.falseNegatives << std::flush; std::cout << "\ntotalWeight: " << totalWeight << std::flush; } unsigned long setNum=0; for(RESULTSETSCONT::iterator it=resultFold.begin(); it!=resultFold.end(); it++, setNum++) { std::cout << "\n\nSet number " << setNum << std::flush; (*it)->show(learnType); } } ~ResultFold() { //free the memory being pointed to for(unsigned long i=0; i