void ClassificationLearnerNew::EvalData(string trainfile) { int total = 0; int right5 = 0; int right7 = 0; double max, max_p; ifstream ifs(trainfile.c_str()); while (LoadInstance(ifs)) { ForwardProp(); max = -1; max_p = -1; for (int i = 6; i >= 0; i--){ if (((Instance*)inst) -> scores[i] > max) { max = ((Instance*)inst) -> scores[i]; max_p = i; } } if (max_p == 0) right7++; max = -1; max_p = -1; for (int i = 6; i >= 0; i--){ if (i == 1 || i == 2) continue; if (((Instance*)inst) -> scores[i] > max) { max = ((Instance*)inst) -> scores[i]; max_p = i; } } if (max_p == 0) right5++; total++; } cout << "7-choice acc: " << (float)right7 / total << endl; cout << "5-choice acc: " << (float)right5 / total << endl; ifs.close(); }
void ClassificationLearnerNew::EvalData14(string trainfile) { int total = 0; double right14 = 0; double max, max_p; double score0 = 0; int equal0 = 0; ifstream ifs(trainfile.c_str()); while (LoadInstance(ifs)) { ForwardProp(); max = -1; max_p = -1; score0 = ((Instance*)inst) -> scores[0]; for (int i = 6; i >= 0; i--){ if (i == 1 || i == 2) continue; if (((Instance*)inst) -> scores[i] >= max) { max = ((Instance*)inst) -> scores[i]; max_p = i; } } string tmp = inst -> word1; inst -> word1 = inst -> word2; inst -> word2 = tmp; tmp = inst -> tag1; inst -> tag1 = inst -> tag2; inst -> tag2 = tmp; equal0 = 1; ForwardProp(); for (int i = 6; i >= 0; i--){ if (i == 1 || i == 2) continue; if (((Instance*)inst) -> scores[i] > max) { max = ((Instance*)inst) -> scores[i]; max_p = i + 7; } if (((Instance*)inst) -> scores[i] == score0) equal0++; } if (max_p == 0) right14 += 1.0/equal0; total++; } cout << "14-choice acc: " << (float)right14 / total << endl; ifs.close(); }
CInstance::CInstance(CZone* zone, uint8 instanceid) : CZoneEntities(zone) { m_zone = zone; m_instanceid = instanceid; m_commander = 0; m_levelcap = 0; m_lastTimeUpdate = 0; m_lastTimeCheck = 0; m_wipeTimer = 0; m_status = INSTANCE_NORMAL; m_progress = 0; m_stage = 0; memset(&m_entryloc, 0, sizeof m_entryloc); LoadInstance(); m_startTime = gettick(); }