void prev_func(void) { struct func *func, *func2; Channel *chan = &ch[scope.select]; for (func = &funcarray[0]; func < &funcarray[funccount]; func++) { if (chan->signal == &func->signal) break; } if (func == &funcarray[funccount]) func = &funcarray[funccount-1]; else if (func == &funcarray[0]) func = &funcarray[funccount-1]; else func --; /* At this point, func points to the candidate function structure. * See if it's valid and go further backwards if it isn't */ func2 = func; do { if (func->isvalid(&func->signal)) { recall(&func->signal); return; } func --; if (func < &funcarray[0]) func = &funcarray[funccount-1]; } while (func != func2); /* If we're here, it's because we went through all the functions * without finding one that returned valid. No choice but to * clear the channel. */ recall(NULL); }
void lookupInput(){ //Catch empty commands if (args[0] == NULL){ return; } //Determine which command was executed if (strncmp(args[0], "exit", 4) == 0){ keepAlive = 0; }else if (strncmp(args[0], "history", 7) == 0){ if (count == 2 && atoi(args[1]) > 0){ showHistory(atoi(args[1])); }else{ showHistory(10); } }else if (strncmp(args[0], "recall", 6) == 0){ recall(atoi(args[1]) - 1); }else{ int pid = fork(); if (!pid){ execvp(args[0], args); //error handling if exec doesnt work printf("Please enter a valid command.\n"); exit(1); }else{ wait(NULL); //sleep(2); } } }
double ConfusionMatrix::fscore(int category) { double p = precision(category); double r = recall(category); if((p + r) == 0.0) return 0.0; return (2 * p * r) / (p + r); }
void Saliency::Evaluate(const string gtImgsW, const string &salDir, const string &resName) { vector<vecD> prec(SAL_TYPE_NUM), recall(SAL_TYPE_NUM); static const int SHOW_COLOR_NUM = 7; static const char* colorShow[SHOW_COLOR_NUM] = {"'k'", "'b'", "'g'", "'r'", "'c'", "'m'", "'y'"}; FILE* f = fopen(resName.c_str(), "w"); CV_Assert(f != NULL); fprintf(f, "clear;\nclose all;\nclc;\nhold on;\nfigure(1);\n\n"); #pragma omp parallel for for (int i = 0; i < SAL_TYPE_NUM; i++) Evaluate(salDir + "*" + SAL_TYPE_DES[i] + ".png", gtImgsW, prec[i], recall[i]); string leglendStr("legend("); for (int i = 0; i < SAL_TYPE_NUM; i++) { string strPre = format("Precision%s", SAL_TYPE_DES[i]); string strRecal = format("Recall%s", SAL_TYPE_DES[i]); int dim = PrintVector(f, recall[i], strRecal); PrintVector(f, prec[i], strPre, dim); fprintf(f, "plot(%s, %s, %s, 'linewidth', 2);\n\n", strRecal.c_str(), strPre.c_str(), colorShow[i % SHOW_COLOR_NUM]); leglendStr += format("'%s', ", SAL_TYPE_DES[i] + 1); } leglendStr.resize(leglendStr.size() - 2); leglendStr += ");"; fprintf(f, "hold off;\nxlabel('Recall');\nylabel('Precision');\n\n%s\ngrid on;\n", leglendStr.c_str()); fprintf(f, "\n\nfigure(2);hold on;\n"); for (int i = 0; i < SAL_TYPE_NUM; i++) fprintf(f, "plot(Recall%s, %s, 'linewidth', 2);\n", SAL_TYPE_DES[i], colorShow[i % SHOW_COLOR_NUM]); fprintf(f, "%s\nhold off;\nxlabel('Threshold');\nylabel('Recall');\ngrid on;", leglendStr.c_str()); fclose(f); CmLog::LogProgress("Evaluation finished%-40s\n", ""); }
void console_down() { if( remempos == rememend ) return; // already at newest remempos = (remempos+1) % LEN; recall(); }
double CoverMetrics::f1score() const { double p = precision(); double r = recall(); if (p + r < std::numeric_limits<double>::epsilon()) { return std::sqrt(-1); // return NaN } return 2*p*r/(p + r); }
void writeLogfileEntry(std::ofstream &ofLog, const std::string &sFilename, int tp, int fp, int fn) { ofLog << sFilename << std::endl; ofLog << "# faces: " << tp+fn; ofLog << ", # detected faces: " << tp+fp << std::endl; ofLog << "tp = " << tp << ", fp = " << fp << ", fn = " << fn; ofLog << ", pr = " << precision(tp, fp); ofLog << ", rc = " << recall(tp, fn) << std::endl; ofLog.flush(); }
void nnet::recall() { if( ::exec_map->empty() ) { // recall synchronous layers first { MapPtr nodes = ::root_map->get( "Nodes" ); Map::iterator i = nodes->begin(); Map::iterator iend = nodes->end(); while( i != iend ) { NodeLayerPtr node = nodes->get( i ); BooleanPtr enabled( node->get( "enabled" ) ); if( !node->asyncRecallOrder() && enabled->get() ) { recall( node ); } i++; } } // then recall async layers { RecallOrder::iterator i = recall_order.order.begin(); RecallOrder::iterator iend = recall_order.order.end(); while( i != iend ) { i->node->recall( i->neuron ); i++; } } } else { try { ExecEnginePtr exec( ::exec_map->first() ); exec->recall(); } catch( std::exception& e ) { LOG_EXCEPTION_E( e ); error::std_exception( "nnet::Recall() running ExecEngine", e.what() ); return; } catch( ... ) { LOG_EXCEPTION; error::alert( "Critical exception in ExecEngine!" ); } } nnet::global::recall_signal(); }
void console_up() { if( (rememend+1)%LEN == remempos ) return; // already at oldest int pos = (remempos+LEN-1) % LEN; if( !rememory[pos] ) return; // older entry is NULL remempos = pos; recall(); }
void ConfusionMatrix::print_summary() { // overall counts and summary cout.precision(4); cout << "== Summary ==" << endl; cout << setw(23) <<"Correctly classified:" << setw(12) << right << correct << setw(10) << right << accuracy() * 100 << "%" << endl; cout << setw(23) << "Incorrectly classified:" << setw(12) << right << incorrect << setw(10) << right << error() * 100 << "%" << endl; cout << setw(23) << "Total classifications:" << setw(12) << right << correct + incorrect << endl << endl; // determine the width of the left (category name) column int max_name_length = 0; for(int category = 1; category <= data_set->categories_size(); category++) if(data_set->category_feature()->names[category].length() > max_name_length) max_name_length = data_set->category_feature()->names[category].length(); if(average_row_name.length() > max_name_length) max_name_length = average_row_name.length(); max_name_length += 1; // detailed category information cout << "== Category Performance ==" << endl; cout << setw(max_name_length) << ""; cout << setw(9) << right << "True +"; cout << setw(9) << right << "False +"; cout << setw(9) << right << "True -"; cout << setw(9) << right << "False -"; cout << setw(9) << right << "Precis."; cout << setw(9) << right << "Recall"; cout << setw(9) << right << "F-score" << endl; for(int category = 1; category <= data_set->categories_size(); category++) { cout << setw(max_name_length) << data_set->category_feature()->names[category]; cout << setw(9) << tp(category); cout << setw(9) << fp(category); cout << setw(9) << tn(category); cout << setw(9) << fn(category); cout << setw(8) << precision(category) * 100 << "%"; cout << setw(8) << recall(category) * 100 << "%"; cout << setw(8) << fscore(category) * 100 << "%" << endl; } cout << setw(max_name_length) << average_row_name; cout << setw(9) << avg_tp(); cout << setw(9) << avg_fp(); cout << setw(9) << avg_tn(); cout << setw(9) << avg_fn(); cout << setw(8) << avg_precision() * 100 << "%"; cout << setw(8) << avg_recall() * 100 << "%"; cout << setw(8) << avg_fscore() * 100 << "%" << endl; }
/// Return a map containing all metrics. StringMapDouble CoverMetrics::all() const { StringMapDouble m; m["tp"] = tp(); m["fp"] = fp(); m["tn"] = tn(); m["fn"] = fn(); m["precision"] = precision(); m["recall"] = recall(); m["f1score"] = f1score(); m["accuracy"] = accuracy(); m["fprate"] = fprate(); m["specificity"] = specificity(); m["fnrate"] = fnrate(); m["matthews"] = matthews(); return m; }
static QState uiMenuCalibratePause(struct UI *me) { switch (Q_SIG(me)) { case Q_ENTRY_SIG: /* Process any event that will cause an exit out of calibration mode that we got while we were away doing the ADC processing. */ recall(me); /* Read the temperature fairly often. We only wait for 5/32 seconds here. We must wait for more than one tick so that the recorder, which has a lower priority, gets a chance to process its own ticks before ours and hence get the ADC when required. */ QActive_armX((QActive*)me, 1, 5); return Q_HANDLED(); case Q_TIMEOUT1_SIG: me->temperatureWaits = 0; return Q_TRAN(uiMenuCalibrateTemperatureStart); } return Q_SUPER(uiMenuCalibrate); }
/* Warth's recursion. Hi Alessandro! */ HParseResult* h_do_parse(const HParser* parser, HParseState *state) { HParserCacheKey *key = a_new(HParserCacheKey, 1); key->input_pos = state->input_stream; key->parser = parser; HParserCacheValue *m = recall(key, state); // check to see if there is already a result for this object... if (!m) { // It doesn't exist, so create a dummy result to cache HLeftRec *base = a_new(HLeftRec, 1); base->seed = NULL; base->rule = parser; base->head = NULL; h_slist_push(state->lr_stack, base); // cache it h_hashtable_put(state->cache, key, cached_lr(state, base)); // parse the input HParseResult *tmp_res = perform_lowlevel_parse(state, parser); // the base variable has passed equality tests with the cache h_slist_pop(state->lr_stack); // update the cached value to our new position HParserCacheValue *cached = h_hashtable_get(state->cache, key); assert(cached != NULL); cached->input_stream = state->input_stream; // setupLR, used below, mutates the LR to have a head if appropriate, so we check to see if we have one if (NULL == base->head) { h_hashtable_put(state->cache, key, cached_result(state, tmp_res)); return tmp_res; } else { base->seed = tmp_res; HParseResult *res = lr_answer(key, state, base); return res; } } else { // it exists! state->input_stream = m->input_stream; if (PC_LEFT == m->value_type) { setupLR(parser, state, m->left); return m->left->seed; } else { return m->right; } } }
void UIPopupCenter::forgetAboutWrongColorDepth(QWidget *pParent) { recall(pParent, "remindAboutWrongColorDepth"); }
bool command_executor::execute_command(const hotkey_command& cmd, int /*index*/, bool press) { // hotkey release handling if (!press) { switch(cmd.id) { // release a scroll key, un-apply scrolling in the given direction case HOTKEY_SCROLL_UP: scroll_up(false); break; case HOTKEY_SCROLL_DOWN: scroll_down(false); break; case HOTKEY_SCROLL_LEFT: scroll_left(false); break; case HOTKEY_SCROLL_RIGHT: scroll_right(false); break; default: return false; // nothing else handles a hotkey release } return true; } // hotkey press handling switch(cmd.id) { case HOTKEY_SCROLL_UP: scroll_up(true); break; case HOTKEY_SCROLL_DOWN: scroll_down(true); break; case HOTKEY_SCROLL_LEFT: scroll_left(true); break; case HOTKEY_SCROLL_RIGHT: scroll_right(true); break; case HOTKEY_CYCLE_UNITS: cycle_units(); break; case HOTKEY_CYCLE_BACK_UNITS: cycle_back_units(); break; case HOTKEY_ENDTURN: end_turn(); break; case HOTKEY_UNIT_HOLD_POSITION: unit_hold_position(); break; case HOTKEY_END_UNIT_TURN: end_unit_turn(); break; case HOTKEY_LEADER: goto_leader(); break; case HOTKEY_UNDO: undo(); break; case HOTKEY_REDO: redo(); break; case HOTKEY_TERRAIN_DESCRIPTION: terrain_description(); break; case HOTKEY_UNIT_DESCRIPTION: unit_description(); break; case HOTKEY_RENAME_UNIT: rename_unit(); break; case HOTKEY_SAVE_GAME: save_game(); break; case HOTKEY_SAVE_REPLAY: save_replay(); break; case HOTKEY_SAVE_MAP: save_map(); break; case HOTKEY_LOAD_GAME: load_game(); break; case HOTKEY_TOGGLE_ELLIPSES: toggle_ellipses(); break; case HOTKEY_TOGGLE_GRID: toggle_grid(); break; case HOTKEY_STATUS_TABLE: status_table(); break; case HOTKEY_RECALL: recall(); break; case HOTKEY_LABEL_SETTINGS: label_settings(); break; case HOTKEY_RECRUIT: recruit(); break; case hotkey::HOTKEY_REPEAT_RECRUIT: repeat_recruit(); break; case HOTKEY_SPEAK: speak(); break; case HOTKEY_SPEAK_ALLY: whisper(); break; case HOTKEY_SPEAK_ALL: shout(); break; case HOTKEY_CREATE_UNIT: create_unit(); break; case HOTKEY_CHANGE_SIDE: change_side(); break; case HOTKEY_KILL_UNIT: kill_unit(); break; case HOTKEY_PREFERENCES: preferences(); break; case HOTKEY_OBJECTIVES: objectives(); break; case HOTKEY_UNIT_LIST: unit_list(); break; case HOTKEY_STATISTICS: show_statistics(); break; case HOTKEY_STOP_NETWORK: stop_network(); break; case HOTKEY_START_NETWORK: start_network(); break; case HOTKEY_LABEL_TEAM_TERRAIN: label_terrain(true); break; case HOTKEY_LABEL_TERRAIN: label_terrain(false); break; case HOTKEY_CLEAR_LABELS: clear_labels(); break; case HOTKEY_SHOW_ENEMY_MOVES: show_enemy_moves(false); break; case HOTKEY_BEST_ENEMY_MOVES: show_enemy_moves(true); break; case HOTKEY_DELAY_SHROUD: toggle_shroud_updates(); break; case HOTKEY_UPDATE_SHROUD: update_shroud_now(); break; case HOTKEY_CONTINUE_MOVE: continue_move(); break; case HOTKEY_SEARCH: search(); break; case HOTKEY_HELP: show_help(); break; case HOTKEY_CHAT_LOG: show_chat_log(); break; case HOTKEY_USER_CMD: user_command(); break; case HOTKEY_CUSTOM_CMD: custom_command(); break; case HOTKEY_AI_FORMULA: ai_formula(); break; case HOTKEY_CLEAR_MSG: clear_messages(); break; case HOTKEY_LANGUAGE: change_language(); break; case HOTKEY_REPLAY_PLAY: play_replay(); break; case HOTKEY_REPLAY_RESET: reset_replay(); break; case HOTKEY_REPLAY_STOP: stop_replay(); break; case HOTKEY_REPLAY_NEXT_TURN: replay_next_turn(); break; case HOTKEY_REPLAY_NEXT_SIDE: replay_next_side(); break; case HOTKEY_REPLAY_NEXT_MOVE: replay_next_move(); break; case HOTKEY_REPLAY_SHOW_EVERYTHING: replay_show_everything(); break; case HOTKEY_REPLAY_SHOW_EACH: replay_show_each(); break; case HOTKEY_REPLAY_SHOW_TEAM1: replay_show_team1(); break; case HOTKEY_REPLAY_SKIP_ANIMATION: replay_skip_animation(); break; case HOTKEY_REPLAY_EXIT: replay_exit(); break; case HOTKEY_WB_TOGGLE: whiteboard_toggle(); break; case HOTKEY_WB_EXECUTE_ACTION: whiteboard_execute_action(); break; case HOTKEY_WB_EXECUTE_ALL_ACTIONS: whiteboard_execute_all_actions(); break; case HOTKEY_WB_DELETE_ACTION: whiteboard_delete_action(); break; case HOTKEY_WB_BUMP_UP_ACTION: whiteboard_bump_up_action(); break; case HOTKEY_WB_BUMP_DOWN_ACTION: whiteboard_bump_down_action(); break; case HOTKEY_WB_SUPPOSE_DEAD: whiteboard_suppose_dead(); break; case HOTKEY_SELECT_HEX: select_hex(); break; case HOTKEY_DESELECT_HEX: deselect_hex(); break; case HOTKEY_MOVE_ACTION: move_action(); break; case HOTKEY_SELECT_AND_ACTION: select_and_action(); break; case HOTKEY_ACCELERATED: toggle_accelerated_speed(); break; case LUA_CONSOLE: lua_console(); break; case HOTKEY_ZOOM_IN: zoom_in(); break; case HOTKEY_ZOOM_OUT: zoom_out(); break; case HOTKEY_ZOOM_DEFAULT: zoom_default(); break; case HOTKEY_MAP_SCREENSHOT: map_screenshot(); break; case HOTKEY_QUIT_TO_DESKTOP: quit_confirmation::quit_to_desktop(); break; case HOTKEY_QUIT_GAME: quit_confirmation::quit_to_title(); break; default: return false; } return true; }
double Accuracy::F1() const { auto P = precision(); auto R = recall(); return (2.0 * P * R) / (P + R); }
benchmarkResult benchmarkDetectionBase(const std::string &sAlgo, const std::string &sGrndtr, double threshold, bool writeLogFile, std::vector<FaceObject> &vAlgoGes, std::vector<FaceObject> &vGrndtrGes) { QString qAlgo = sAlgo.c_str(); QDir dirAlgo = qAlgo; std::string sFullpathAlgo, sFilename, sFullpathGrndtr; int tp = 0; benchmarkResult bRes; int iNumFacesGrndtr = 0; int iNumFacesAlgo = 0; int iSeqNo = 0; // Open logfile std::ofstream ofLog; if(writeLogFile) bRes.logFileName = openLogfile(ofLog, sAlgo, sGrndtr, threshold, "benchmarkDetection"); // Iterate folders dirAlgo.setFilter(QDir::Files); QDirIterator itDirAlgo(dirAlgo); while(itDirAlgo.hasNext()) { itDirAlgo.next(); sFullpathAlgo = itDirAlgo.filePath().toUtf8().constData(); sFilename = itDirAlgo.fileName().toUtf8().constData(); sFullpathGrndtr = sGrndtr + "/" + sFilename; std::vector<FaceObject> vAlgo = readObjectFile(sFullpathAlgo); std::vector<FaceObject> vGrndtr = readObjectFile(sFullpathGrndtr); if(!QFile(sFullpathAlgo.c_str()).exists() || !QFile(sFullpathGrndtr.c_str()).exists()) continue; // Go on if ground truth file and algo file exist. iNumFacesAlgo += vAlgo.size(); iNumFacesGrndtr += vGrndtr.size(); if(vAlgo.size() != 0 && vGrndtr.size() != 0) { // Compare FaceObjects of Algo and Grndtr double overlap[vAlgo.size()][vGrndtr.size()]; for(size_t i=0; i<vAlgo.size(); i++) { for(size_t j=0; j<vGrndtr.size(); j++) { overlap[i][j] = getOverlapRelToGrndtr(vAlgo[i], vGrndtr[j]); } } // Count number of TP for(size_t k=0; k<vAlgo.size(); k++) { double dHighestOverlap = -1.0; int iHighest = 0; int jHighest = 0; // get highest overlap value for(size_t i=0; i<vAlgo.size(); i++) { for(size_t j=0; j<vGrndtr.size(); j++) { if(overlap[i][j] > dHighestOverlap) { dHighestOverlap = overlap[i][j]; iHighest = i; jHighest = j; } } } // Check whether it is a TP if(dHighestOverlap >= threshold) tp++; else break; // Set row & col to -1 => Don't consider them in future for(size_t i=0; i<vAlgo.size(); i++) { overlap[i][jHighest] = -1.0; } for(size_t j=0; j<vGrndtr.size(); j++) { overlap[iHighest][j] = -1.0; } // Write seqNo to FO Grndtr and FO Algo vAlgo[iHighest].iSequentialNumber = iSeqNo; vGrndtr[jHighest].iSequentialNumber = iSeqNo; iSeqNo++; } // Add FOs to return-vectors for(size_t i=0; i<vAlgo.size(); i++) vAlgoGes.push_back(vAlgo[i]); for(size_t i=0; i<vGrndtr.size(); i++) vGrndtrGes.push_back(vGrndtr[i]); } int fp = vAlgo.size() - tp; int fn = vGrndtr.size() - tp; bRes.truePositives += tp; bRes.falsePositives += fp; bRes.falseNegatives += fn; // Write logfile entry if(writeLogFile) writeLogfileEntry(ofLog, sFilename, tp, fp, fn); tp = 0; } bRes.precision = precision(bRes.truePositives, bRes.falsePositives); bRes.recall = recall(bRes.truePositives, bRes.falseNegatives); // Write logfile summary if(writeLogFile) writeSummaryToLogFile(ofLog, bRes, iNumFacesGrndtr, iNumFacesAlgo); return bRes; }
benchmarkResult benchmarkRecognition(const std::string &sAlgo, const std::string &sGrndtr, double threshold) { benchmarkResult bRes; int iNumFacesGrndtr = 0; int iNumFacesAlgo = 0; std::map<int, bool> mAllocation; int iNumberOfAllocations = 0; bool bAllocationChanged = true; // Open logfile //std::ofstream ofLog; //openLogfile(ofLog, sAlgo, sGrndtr, threshold, "benchmarkRecognition"); std::map<int, std::vector<int> > mSeqNoAlgo, mSeqNoGrndtr; // objectID -> seqNumbers std::map<int, int> mObjectIDAlgo, mObjectIDGrndtr; // seqNo -> objectID std::vector<FaceObject> vAlgo, vGrndtr; benchmarkDetectionBase(sAlgo, sGrndtr, threshold, false, vAlgo, vGrndtr); // Find out which FOs have the same ID in Algo for(size_t i=0; i<vAlgo.size(); i++) { //std::cout << "vAlgo[" << i << "].iSequentialNumber: " << vAlgo[i].iSequentialNumber << std::endl; if(vAlgo[i].iSequentialNumber == -1) continue; mSeqNoAlgo[vAlgo[i].objectID].push_back(vAlgo[i].iSequentialNumber); mObjectIDAlgo[vAlgo[i].iSequentialNumber] = vAlgo[i].objectID; iNumFacesAlgo++; } // Find out which FOs have the same ID in Grndtr for(size_t i=0; i<vGrndtr.size(); i++) { if(mObjectIDAlgo.count(vGrndtr[i].iSequentialNumber) == 0) continue; mSeqNoGrndtr[vGrndtr[i].objectID].push_back(vGrndtr[i].iSequentialNumber); mObjectIDGrndtr[vGrndtr[i].iSequentialNumber] = vGrndtr[i].objectID; iNumFacesGrndtr++; mAllocation[vGrndtr[i].iSequentialNumber] = false; //if(vGrndtr[i].iSequentialNumber==-1) std::cout << "-1: " << sFullpathGrndtr << std::endl; } //std::cout << "mObjectIDGrndtr.size()=" << mObjectIDGrndtr.size() << std::endl; //std::cout << "iNumFacesGrndtr=" << iNumFacesGrndtr << std::endl; //std::cout << "mAllocation.size()=" << mAllocation.size() << std::endl; // Compute allocation of Grndtr IDs and Algo IDs while(bAllocationChanged) { bAllocationChanged = false; std::map<int, bool>::iterator itAllocation; for(itAllocation=mAllocation.begin(); itAllocation!=mAllocation.end(); /*itAllocation++*/) { if(itAllocation->second) { itAllocation++; continue; // Allocation is already true } //std::cout << "itAllocation->first: " << itAllocation->first << std::endl; //if(mObjectIDGrndtr.find(itAllocation->first) == mObjectIDGrndtr.end() || mObjectIDAlgo.find(itAllocation->first) == mObjectIDAlgo.end()) if(mObjectIDGrndtr.count(itAllocation->first) == 0 || mObjectIDAlgo.count(itAllocation->first) == 0) { // SeqNo does not exist -> False positive or false negative -> We do not consider them in recognition benchmark. //std::map<int, bool>::iterator itTmp = itAllocation; //std::cout << "out: " << itAllocation->first << std::endl; //itAllocation--; mAllocation.erase(itAllocation++); continue; } int iAllocationGain = 0; int idGrndtr = mObjectIDGrndtr[itAllocation->first]; int idAlgo = mObjectIDAlgo[itAllocation->first]; std::vector<int> vAllocationChanged; for(size_t j=0; j<mSeqNoGrndtr[idGrndtr].size(); j++) { int iSeqNo = mSeqNoGrndtr[idGrndtr][j]; if(mObjectIDAlgo[iSeqNo] == idAlgo && !mAllocation[iSeqNo]) { iAllocationGain++; vAllocationChanged.push_back(iSeqNo); } else if(mObjectIDAlgo[iSeqNo] != idAlgo && mAllocation[iSeqNo]) { iAllocationGain--; vAllocationChanged.push_back(iSeqNo); } //if(iSeqNo == -1) std::cout << "-1 in for(size_t j=0; j<mSeqNoGrndtr[idGrndtr].size(); j++) " << idAlgo << " " << idGrndtr << std::endl; } for(size_t j=0; j<mSeqNoAlgo[idAlgo].size(); j++) { int iSeqNo = mSeqNoAlgo[idAlgo][j]; if(mObjectIDGrndtr[iSeqNo] == idGrndtr && !mAllocation[iSeqNo]) { //iAllocationGain++; //vAllocationChanged.push_back(iSeqNo); } else if(mObjectIDGrndtr[iSeqNo] != idGrndtr && mAllocation[iSeqNo]) { iAllocationGain--; vAllocationChanged.push_back(iSeqNo); } //if(iSeqNo == -1) std::cout << "-1 in for(size_t j=0; j<mSeqNoAlgo[idAlgo].size(); j++) " << idAlgo << " " << idGrndtr << std::endl; } if(iAllocationGain > 0) { iNumberOfAllocations += iAllocationGain; bAllocationChanged = true; for(size_t j=0; j<vAllocationChanged.size(); j++) { mAllocation[vAllocationChanged[j]] = mAllocation[vAllocationChanged[j]] ? false : true; //if(vAllocationChanged[j] == -1) std::cout << "-1 in for(size_t j=0; j<vAllocationChanged.size(); j++) " << idAlgo << " " << idGrndtr << std::endl; } } itAllocation++; } //std::cout << "cnt: " << ++cnt << ", iNumberOfAllocations: " << iNumberOfAllocations << std::endl; } //std::cout << "Allocation:" << std::endl; //printAllocation(mObjectIDAlgo, mObjectIDGrndtr, mAllocation); bRes.truePositives = iNumberOfAllocations; bRes.falseNegatives = mAllocation.size() - iNumberOfAllocations; bRes.recall = recall(bRes.truePositives, bRes.falseNegatives); std::cout << "Number of different persons considered: " << mSeqNoGrndtr.size() << std::endl; std::cout << "Number of different persons recognized by the algorithm: " << mSeqNoAlgo.size() << std::endl; std::cout << "Number of considered faces: " << mAllocation.size() << std::endl; std::cout << "Number of faces recognized correctly: " << iNumberOfAllocations << std::endl; return bRes; }
// Public function to find F-Score = weighted harmonic mean of Precision and Recall float ROC::FScore() { return (2 * precision() * recall()) / (precision() + recall()); }
void CmEvaluation::Evaluate(CStr gtW, CStr &salDir, CStr &resName, vecS &des) { int NumMethod = des.size(); // Number of different methods vector<vecD> precision(NumMethod), recall(NumMethod), tpr(NumMethod), fpr(NumMethod); static const int CN = 21; // Color Number static const char* c[CN] = {"'k'", "'b'", "'g'", "'r'", "'c'", "'m'", "'y'", "':k'", "':b'", "':g'", "':r'", "':c'", "':m'", "':y'", "'--k'", "'--b'", "'--g'", "'--r'", "'--c'", "'--m'", "'--y'" }; FILE* f = fopen(_S(resName), "w"); CV_Assert(f != NULL); fprintf(f, "clear;\nclose all;\nclc;\n\n\n%%%%\nfigure(1);\nhold on;\n"); vecD thr(NUM_THRESHOLD); for (int i = 0; i < NUM_THRESHOLD; i++) thr[i] = i * STEP; PrintVector(f, thr, "Threshold"); fprintf(f, "\n"); vecD mae(NumMethod); for (int i = 0; i < NumMethod; i++) mae[i] = Evaluate_(gtW, salDir, "_" + des[i] + ".png", precision[i], recall[i], tpr[i], fpr[i]); //Evaluate(salDir + "*" + des[i] + ".png", gtW, val[i], recall[i], t); string leglendStr("legend("); vecS strPre(NumMethod), strRecall(NumMethod), strTpr(NumMethod), strFpr(NumMethod); for (int i = 0; i < NumMethod; i++){ strPre[i] = format("Precision_%s", _S(des[i])); strRecall[i] = format("Recall_%s", _S(des[i])); strTpr[i] = format("TPR_%s", _S(des[i])); strFpr[i] = format("FPR_%s", _S(des[i])); PrintVector(f, recall[i], strRecall[i]); PrintVector(f, precision[i], strPre[i]); PrintVector(f, tpr[i], strTpr[i]); PrintVector(f, fpr[i], strFpr[i]); fprintf(f, "plot(%s, %s, %s, 'linewidth', %d);\n", _S(strRecall[i]), _S(strPre[i]), c[i % CN], i < CN ? 2 : 1); leglendStr += format("'%s', ", _S(des[i])); } leglendStr.resize(leglendStr.size() - 2); leglendStr += ");"; string xLabel = "label('Recall');\n"; string yLabel = "label('Precision')\n"; fprintf(f, "hold off;\nx%sy%s\n%s\ngrid on;\naxis([0 1 0 1]);\ntitle('Precision recall curve');\n", _S(xLabel), _S(yLabel), _S(leglendStr)); fprintf(f, "\n\n\n%%%%\nfigure(2);\nhold on;\n"); for (int i = 0; i < NumMethod; i++) fprintf(f, "plot(%s, %s, %s, 'linewidth', %d);\n", _S(strFpr[i]), _S(strTpr[i]), c[i % CN], i < CN ? 2 : 1); xLabel = "label('False positive rate');\n"; yLabel = "label('True positive rate')\n"; fprintf(f, "hold off;\nx%sy%s\n%s\ngrid on;\naxis([0 1 0 1]);\n\n\n%%%%\nfigure(3);\ntitle('ROC curve');\n", _S(xLabel), _S(yLabel), _S(leglendStr)); double betaSqr = 0.3; // As suggested by most papers for salient object detection vecD areaROC(NumMethod, 0), avgFMeasure(NumMethod, 0), maxFMeasure(NumMethod, 0); for (int i = 0; i < NumMethod; i++){ CV_Assert(fpr[i].size() == tpr[i].size() && precision[i].size() == recall[i].size() && fpr[i].size() == precision[i].size()); for (size_t t = 0; t < fpr[i].size(); t++){ double fMeasure = (1+betaSqr) * precision[i][t] * recall[i][t] / (betaSqr * precision[i][t] + recall[i][t]); avgFMeasure[i] += fMeasure/fpr[i].size(); // Doing average like this might have strange effect as in: maxFMeasure[i] = max(maxFMeasure[i], fMeasure); if (t > 0){ areaROC[i] += (tpr[i][t] + tpr[i][t - 1]) * (fpr[i][t - 1] - fpr[i][t]) / 2.0; } } fprintf(f, "%%%5s: AUC = %5.3f, MeanF = %5.3f, MaxF = %5.3f, MAE = %5.3f\n", _S(des[i]), areaROC[i], avgFMeasure[i], maxFMeasure[i], mae[i]); } PrintVector(f, areaROC, "AUC"); PrintVector(f, avgFMeasure, "MeanFMeasure"); PrintVector(f, maxFMeasure, "MaxFMeasure"); PrintVector(f, mae, "MAE"); // methodLabels = {'AC', 'SR', 'DRFI', 'GU', 'GB'}; fprintf(f, "methodLabels = {'%s'", _S(des[0])); for (int i = 1; i < NumMethod; i++) fprintf(f, ", '%s'", _S(des[i])); fprintf(f, "};\n\nbar([MeanFMeasure; MaxFMeasure; AUC]');\nlegend('Mean F_\\beta', 'Max F_\\beta', 'AUC');xlim([0 %d]);\ngrid on;\n", NumMethod+1); fprintf(f, "xticklabel_rotate([1:%d],90, methodLabels,'interpreter','none');\n", NumMethod); fprintf(f, "\n\nfigure(4);\nbar(MAE);\ntitle('MAE');\ngrid on;\nxlim([0 %d]);", NumMethod+1); fprintf(f, "xticklabel_rotate([1:%d],90, methodLabels,'interpreter','none');\n", NumMethod); fclose(f); printf("%-70s\r", ""); }
void UIPopupCenter::forgetAboutPausedVMInput(QWidget *pParent) { recall(pParent, "remindAboutPausedVMInput"); }
/*\ Wait for asynchronous I/O operation to complete. Invalidate id. \*/ int elio_wait(io_request_t *req_id) { int aio_i=0; int rc; rc=0; /* just to remove the compiler warning */ #ifdef PABLO int pablo_code = PABLO_elio_wait; PABLO_start( pablo_code ); #endif if(*req_id != ELIO_DONE ) { # ifdef AIO # if defined(CRAY) # if defined(FFIO) { struct ffsw dumstat, *prdstat=&(cb_fout[*req_id].stat); fffcntl(cb_fout[*req_id].filedes, FC_RECALL, prdstat, &dumstat); if (FFSTAT(*prdstat) == FFERR) ELIO_ERROR(SUSPFAIL,0); } # else { struct iosw *statlist[1]; statlist[0] = &(cb_fout[*req_id].stat); recall(cb_fout[*req_id].filedes, 1, statlist); } # endif # elif defined(AIX) # if !defined(AIX52) && !defined(_AIO_AIX_SOURCE) do { /* I/O can be interrupted on SP through rcvncall ! */ rc =(int)aio_suspend(1, cb_fout_arr+(int)*req_id); } while(rc == -1 && errno == EINTR); # endif # else if((int)aio_suspend((const struct aiocb *const*)(cb_fout_arr+(int)*req_id), 1, NULL) != 0) rc =-1; # endif if(rc ==-1) ELIO_ERROR(SUSPFAIL,0); # if defined(DECOSF) /* on DEC aio_return is required to clean internal data structures */ if(aio_return(cb_fout+(int)*req_id) == -1) ELIO_ERROR(RETUFAIL,0); # endif #endif while(aio_req[aio_i] != *req_id && aio_i < MAX_AIO_REQ) aio_i++; if(aio_i >= MAX_AIO_REQ) ELIO_ERROR(HANDFAIL, aio_i); aio_req[aio_i] = NULL_AIO; *req_id = ELIO_DONE; } #ifdef PABLO PABLO_end(pablo_code); #endif return ELIO_OK; }
void learn( size_t neuron ) { recall( neuron ); }
bool command_executor::execute_command(HOTKEY_COMMAND command, int /*index*/) { switch(command) { case HOTKEY_CYCLE_UNITS: cycle_units(); break; case HOTKEY_CYCLE_BACK_UNITS: cycle_back_units(); break; case HOTKEY_ENDTURN: end_turn(); break; case HOTKEY_UNIT_HOLD_POSITION: unit_hold_position(); break; case HOTKEY_END_UNIT_TURN: end_unit_turn(); break; case HOTKEY_LEADER: goto_leader(); break; case HOTKEY_UNDO: undo(); break; case HOTKEY_REDO: redo(); break; case HOTKEY_UNIT_DESCRIPTION: unit_description(); break; case HOTKEY_RENAME_UNIT: rename_unit(); break; case HOTKEY_SAVE_GAME: save_game(); break; case HOTKEY_SAVE_REPLAY: save_replay(); break; case HOTKEY_SAVE_MAP: save_map(); break; case HOTKEY_LOAD_GAME: load_game(); break; case HOTKEY_TOGGLE_ELLIPSES: toggle_ellipses(); break; case HOTKEY_TOGGLE_GRID: toggle_grid(); break; case HOTKEY_STATUS_TABLE: status_table(); break; case HOTKEY_RECALL: recall(); break; case HOTKEY_RECRUIT: recruit(); break; case hotkey::HOTKEY_REPEAT_RECRUIT: repeat_recruit(); break; case HOTKEY_SPEAK: speak(); break; case HOTKEY_SPEAK_ALLY: whisper(); break; case HOTKEY_SPEAK_ALL: shout(); break; case HOTKEY_CREATE_UNIT: create_unit(); break; case HOTKEY_CHANGE_SIDE: change_side(); break; case HOTKEY_PREFERENCES: preferences(); break; case HOTKEY_OBJECTIVES: objectives(); break; case HOTKEY_UNIT_LIST: unit_list(); break; case HOTKEY_STATISTICS: show_statistics(); break; case HOTKEY_STOP_NETWORK: stop_network(); break; case HOTKEY_START_NETWORK: start_network(); break; case HOTKEY_LABEL_TEAM_TERRAIN: label_terrain(true); break; case HOTKEY_LABEL_TERRAIN: label_terrain(false); break; case HOTKEY_CLEAR_LABELS: clear_labels(); break; case HOTKEY_SHOW_ENEMY_MOVES: show_enemy_moves(false); break; case HOTKEY_BEST_ENEMY_MOVES: show_enemy_moves(true); break; case HOTKEY_DELAY_SHROUD: toggle_shroud_updates(); break; case HOTKEY_UPDATE_SHROUD: update_shroud_now(); break; case HOTKEY_CONTINUE_MOVE: continue_move(); break; case HOTKEY_SEARCH: search(); break; case HOTKEY_HELP: show_help(); break; case HOTKEY_CHAT_LOG: show_chat_log(); break; case HOTKEY_USER_CMD: user_command(); break; case HOTKEY_CUSTOM_CMD: custom_command(); break; case HOTKEY_AI_FORMULA: ai_formula(); break; case HOTKEY_CLEAR_MSG: clear_messages(); break; case HOTKEY_LANGUAGE: change_language(); break; case HOTKEY_PLAY_REPLAY: play_replay(); break; case HOTKEY_RESET_REPLAY: reset_replay(); break; case HOTKEY_STOP_REPLAY: stop_replay(); break; case HOTKEY_REPLAY_NEXT_TURN: replay_next_turn(); break; case HOTKEY_REPLAY_NEXT_SIDE: replay_next_side(); break; case HOTKEY_REPLAY_SHOW_EVERYTHING: replay_show_everything(); break; case HOTKEY_REPLAY_SHOW_EACH: replay_show_each(); break; case HOTKEY_REPLAY_SHOW_TEAM1: replay_show_team1(); break; case HOTKEY_REPLAY_SKIP_ANIMATION: replay_skip_animation(); break; case HOTKEY_WB_TOGGLE: whiteboard_toggle(); break; case HOTKEY_WB_EXECUTE_ACTION: whiteboard_execute_action(); break; case HOTKEY_WB_EXECUTE_ALL_ACTIONS: whiteboard_execute_all_actions(); break; case HOTKEY_WB_DELETE_ACTION: whiteboard_delete_action(); break; case HOTKEY_WB_BUMP_UP_ACTION: whiteboard_bump_up_action(); break; case HOTKEY_WB_BUMP_DOWN_ACTION: whiteboard_bump_down_action(); break; case HOTKEY_WB_SUPPOSE_DEAD: whiteboard_suppose_dead(); break; case HOTKEY_LEFT_MOUSE_CLICK: left_mouse_click(); break; case HOTKEY_RIGHT_MOUSE_CLICK: right_mouse_click(); break; default: return false; } return true; }