📄 coclustering.cc
字号:
ev.printCM(dumpFile); ev.purity_Entropy_MutInfo(dumpFile, isShowingEachCluster); ev.F_measure(dumpFile); ev.micro_avg_precision_recall(rowPrecision, rowRecall, dumpFile); }*/ if (dumpLevel >= MINIMUM_DUMP_LEVEL) // Don't need to check, but... cout << endl << " ### External Row Cluster Validation ###" << endl << endl; if (dumpAccessMode != NO_OPEN_MODE) dumpFile << endl << " ### External Row Cluster Validation ###" << endl << endl; if (statisticsAccessMode != NO_OPEN_MODE) statisticsFile << endl << " ### External Row Cluster Validation ###" << endl << endl; if (isShowingEachCluster){ ev.printCM(cout); ev.printCM(dumpFile); ev.printCM(statisticsFile); } ev.purity_Entropy_MutInfo(isShowingEachCluster, cout, dumpFile, statisticsFile); ev.F_measure(cout, dumpFile, statisticsFile); ev.micro_avg_precision_recall(rowPrecision, rowRecall, cout, dumpFile, statisticsFile); ev.getAccuracy(rowAccuracy, cout, dumpFile, statisticsFile);}void Coclustering::validateColCluster(int numColClass, int *colClassLabel){ ExternalValidity ev(numColClass, numColCluster, numCol, colClassLabel, colCL);/*// if (dumpLevel > MINIMUM_DUMP_LEVEL){ cout << endl << " ### External Column Cluster Validation ###" << endl << endl; if (isShowingEachCluster) ev.printCM(cout); ev.purity_Entropy_MutInfo(cout, isShowingEachCluster); ev.F_measure(cout); ev.micro_avg_precision_recall(rowPrecision, rowRecall, cout);// } if (statisticsAccessMode != NO_OPEN_MODE){ statisticsFile << endl << " ### External Column Cluster Validation ###" << endl << endl; if (isShowingEachCluster) ev.printCM(statisticsFile); ev.purity_Entropy_MutInfo(statisticsFile, isShowingEachCluster); ev.F_measure(statisticsFile); ev.micro_avg_precision_recall(rowPrecision, rowRecall, statisticsFile); } if (dumpAccessMode != NO_OPEN_MODE){ dumpFile << endl << " ### External Column Cluster Validation ###" << endl << endl; if (isShowingEachCluster) ev.printCM(dumpFile); ev.purity_Entropy_MutInfo(dumpFile, isShowingEachCluster); ev.F_measure(dumpFile); ev.micro_avg_precision_recall(rowPrecision, rowRecall, dumpFile); }*/ if (dumpLevel >= MINIMUM_DUMP_LEVEL) // Don't need to check, but... cout << endl << " ### External Column Cluster Validation ###" << endl << endl; if (dumpAccessMode != NO_OPEN_MODE) dumpFile << endl << " ### External Column Cluster Validation ###" << endl << endl; if (statisticsAccessMode != NO_OPEN_MODE) statisticsFile << endl << " ### External Column Cluster Validation ###" << endl << endl; if (isShowingEachCluster){ ev.printCM(cout); ev.printCM(dumpFile); ev.printCM(statisticsFile); } ev.purity_Entropy_MutInfo(isShowingEachCluster, cout, dumpFile, statisticsFile); ev.F_measure(cout, dumpFile, statisticsFile); ev.micro_avg_precision_recall(colPrecision, colRecall, cout, dumpFile, statisticsFile); ev.getAccuracy(colAccuracy, cout, dumpFile, statisticsFile);}double Coclustering::getRowPrecision(){ return rowPrecision;}double Coclustering::getRowRecall(){ return rowRecall;}double Coclustering::getRowAccuracy(){ return rowAccuracy;}double Coclustering::getColPrecision(){ return colPrecision;}double Coclustering::getColRecall(){ return colRecall;}double Coclustering::getColAccuracy(){ return colAccuracy;}void Coclustering::clearMark4Row(){ for (int i = 0; i < numRow; i++) isRowMarked[i] = false;}void Coclustering::clearMark4Col(){ for (int i = 0; i < numCol; i++) isColMarked[i] = false;}void Coclustering::checkDumpLevel4Cocluster(ostream &os){ if (dumpLevel == MAXIMUM_DUMP_LEVEL){ os << " Row cluster labels:" << endl; os << " "; for (int r = 0; r < numRow; r++) os << rowCL[r] << " "; os << endl << " Col cluster labels:" << endl; os << " "; for (int c = 0; c < numCol; c++) os << colCL[c] << " "; os << endl << " Compressed matrix:" << endl; for (int rc = 0; rc < numRowCluster; rc++){ os << " "; for (int cc = 0; cc < numColCluster; cc++) os << Acompressed[rc][cc] << " "; os << endl; } }}void Coclustering::checkDumpLevel4InitialObjectValue(){ switch (dumpLevel){ case MINIMUM_DUMP_LEVEL: case MAXIMUM_DUMP_LEVEL: break; case BATCH_UPDATE_DUMP_LEVEL: case LOCAL_SEARCH_DUMP_LEVEL: cout << classPrefix << "Initial Objective Function Value = " << objValue << endl; break; } if (objectiveAccessMode != NO_OPEN_MODE) objectiveFile << "0 " << objValue << endl; if (isComputingOneWayObjective){ switch (dumpLevel){ case MINIMUM_DUMP_LEVEL: break; case BATCH_UPDATE_DUMP_LEVEL: case LOCAL_SEARCH_DUMP_LEVEL: cout << classPrefix << "Initial Obj.Func. of one-way Row = " << objValue4RowCluster << endl; cout << classPrefix << "Initial Obj.Func. of one-way Col = " << objValue4ColCluster << endl; break; case MAXIMUM_DUMP_LEVEL: dumpFile << classPrefix << "Initial Obj.Func. of one-way Row = " << objValue4RowCluster << endl; dumpFile << classPrefix << "Initial Obj.Func. of one-way Col = " << objValue4ColCluster << endl; break; } if (statisticsAccessMode != NO_OPEN_MODE){ statisticsFile << classPrefix << "Initial Obj.Func. of one-way Row = " << objValue4RowCluster << endl; statisticsFile << classPrefix << "Initial Obj.Func. of one-way Col = " << objValue4ColCluster << endl; } } }void Coclustering::checkDumpLevel4FinalObjectValue(){ switch (dumpLevel){ case MINIMUM_DUMP_LEVEL: case MAXIMUM_DUMP_LEVEL: break; case BATCH_UPDATE_DUMP_LEVEL: case LOCAL_SEARCH_DUMP_LEVEL: cout << classPrefix << "Final Objective Function Value = " << objValue << endl; break; }}void Coclustering::checkDumpLevel4Centroid(double **centroid, int row, int col){ if (dumpLevel == MAXIMUM_DUMP_LEVEL){ char *title = NULL; if (row == numRowCluster && col == numCol){ title = ROW_CENTROID; } else if (row == numColCluster && col == numRow){ title = COL_CENTROID; } else { cout << " Invalid argument in checkDumpLevel4Centroid(): " << row << " " << col << endl; dumpFile << " Invalid argument in checkDumpLevel4Centroid(): " << row << " " << col << endl; exit(EXIT_FAILURE); } dumpFile << endl << title << endl; for (int r = 0; r < row; r++){ dumpFile << " "; for (int c = 0; c < col; c++) dumpFile << centroid[r][c] << " "; dumpFile << endl; } dumpFile << endl; }}void Coclustering::checkDumpLevel4NumOfChange(char *token, int numChange){ switch (dumpLevel){ case MINIMUM_DUMP_LEVEL: case BATCH_UPDATE_DUMP_LEVEL: break; case LOCAL_SEARCH_DUMP_LEVEL: cout << " ### " << numChange << " " << token << " changing cluster label(s) ###" << endl; break; case MAXIMUM_DUMP_LEVEL: dumpFile << " ### " << numChange << " " << token << " changing cluster label(s) ###" << endl; break; }}void Coclustering::checkDumpLevel4ReversedRow(){ if (isTakingReverse){ computeNumReversedRow(); switch (dumpLevel){ case MINIMUM_DUMP_LEVEL: case BATCH_UPDATE_DUMP_LEVEL: break; case LOCAL_SEARCH_DUMP_LEVEL: cout << " ### " << numReversedRow << " reversed row(s) ###" << endl; break; case MAXIMUM_DUMP_LEVEL: for (int i = 0; i < numRow; i++){ if (isReversed[i]) dumpFile << "-"; dumpFile << i << ", "; } dumpFile << endl; dumpFile << " ### " << numReversedRow << " reversed row(s) ###" << endl; break; } if (statisticsAccessMode != NO_OPEN_MODE) statisticsFile << " ### " << numReversedRow << " reversed row(s) ###" << endl; }}void Coclustering::checkDumpLevel4BatchUpdate(char *token){ switch (dumpLevel){ case MINIMUM_DUMP_LEVEL: break; case BATCH_UPDATE_DUMP_LEVEL: case LOCAL_SEARCH_DUMP_LEVEL: cout << classPrefix << token << "BatchUpdate()" << endl; break; case MAXIMUM_DUMP_LEVEL: dumpFile << classPrefix << token << "BatchUpdate()" << endl; break; }}void Coclustering::checkDumpLevel4BatchUpdate(char *token, int num){ if (objectiveAccessMode != NO_OPEN_MODE){ char *objValueType = NULL; if (strcmp(token, "row") == 0) objValueType = "1 "; else if (strcmp(token, "col") == 0) objValueType = "2 "; else if (strcmp(token, "both") == 0) // for Govaert's algorithm objValueType = "2 "; else { cout << " Invalid argument in checkDumpLevel4BatchUpdate(): " << token << endl; if (dumpLevel == MAXIMUM_DUMP_LEVEL) dumpFile << " Invalid argument in checkDumpLevel4BatchUpdate(): " << token << endl; exit(EXIT_FAILURE); } objectiveFile << objValueType << objValue << endl; } switch (dumpLevel){ case MINIMUM_DUMP_LEVEL: break; case BATCH_UPDATE_DUMP_LEVEL: case LOCAL_SEARCH_DUMP_LEVEL: cout << classPrefix << token << "BatchUpdate[" << num << "] = " << objValue << endl; break; case MAXIMUM_DUMP_LEVEL: dumpFile << classPrefix << token << "BatchUpdate[" << num << "] = " << objValue << endl; break; }}void Coclustering::checkDumpLevel4DeltaTrace(char *token, int id, int toCluster, double delta, double minDelta){ if (dumpLevel == MAXIMUM_DUMP_LEVEL){ dumpFile << " " << token << "[" << id << "]("; if (strcmp(token, "row") == 0) dumpFile << rowCL[id]; else if (strcmp(token, "col") == 0) dumpFile << colCL[id]; else { cout << " Invalid argument in checkDumpLevel4DeltaTrace(): " << token << endl; dumpFile << " Invalid argument in checkDumpLevel4DeltaTrace(): " << token << endl; exit(EXIT_FAILURE); } dumpFile << "=>" << toCluster << "): " << delta << " + " << minDelta << " = " << (delta+minDelta) << endl; }}void Coclustering::checkDumpLevel4LocalSearch(char *token){ switch (dumpLevel){ case MINIMUM_DUMP_LEVEL: break; case BATCH_UPDATE_DUMP_LEVEL: case LOCAL_SEARCH_DUMP_LEVEL: cout << classPrefix << token << "LocalSearch()" << endl; break; case MAXIMUM_DUMP_LEVEL: dumpFile << classPrefix << token << "LocalSearch()" << endl; break; }}void Coclustering::checkDumpLevel4LocalSearch(char *token, int id, int from, int to, double change){ switch (dumpLevel){ case MINIMUM_DUMP_LEVEL: break; case LOCAL_SEARCH_DUMP_LEVEL: cout << classPrefix << token << "LocalSearch[" << id << "](" << from << "=>" << to << ") = " << change << endl; break; case MAXIMUM_DUMP_LEVEL: dumpFile << classPrefix << token << "LocalSearch[" << id << "](" << from << "=>" << to << ") = " << change << endl; break; }}void Coclustering::checkDumpLevel4NumOfChain(char *token, int num, double *totalChange){ if (num == 0){ switch (dumpLevel){ case MINIMUM_DUMP_LEVEL: case BATCH_UPDATE_DUMP_LEVEL: break; case LOCAL_SEARCH_DUMP_LEVEL: cout << " !!! No " << token << " chain taken !!!" << endl; break; case MAXIMUM_DUMP_LEVEL: dumpFile << " !!! No " << token << " chain taken !!!" << endl; break; } } else { char *objValueType = NULL; if (strcmp(token, "row") == 0) objValueType = "3 "; else if (strcmp(token, "col") == 0) objValueType = "4 "; else { switch (dumpLevel){ case MINIMUM_DUMP_LEVEL: case BATCH_UPDATE_DUMP_LEVEL: break; case LOCAL_SEARCH_DUMP_LEVEL: cout << " Invalid argument in checkDumpLevel4NumOfChain(): " << token << endl; break; case MAXIMUM_DUMP_LEVEL: dumpFile << " Invalid argument in checkDumpLevel4NumOfChain(): " << token << endl; break; } exit(EXIT_FAILURE); } if (objectiveAccessMode != NO_OPEN_MODE) for (int i = 0; i < num+1; i++) objectiveFile << objValueType << (objValue + totalChange[i]) << endl; objValue += totalChange[num]; switch (dumpLevel){ case MINIMUM_DUMP_LEVEL: case BATCH_UPDATE_DUMP_LEVEL: break; case LOCAL_SEARCH_DUMP_LEVEL: cout << " ### " << (num+1) << " " << token << " chain(s) taken ###" << endl; break; case MAXIMUM_DUMP_LEVEL: dumpFile << " ### " << (num+1) << " " << token << " chain(s) taken ###" << endl; break; } } } void Coclustering::checkDumpLevel4PingPong(char *token, int num){ switch (dumpLevel){ case MINIMUM_DUMP_LEVEL: break; case BATCH_UPDATE_DUMP_LEVEL: case LOCAL_SEARCH_DUMP_LEVEL: cout << classPrefix << token << "PingPoing(): numIteration(" << num << ")" << endl; if (strcmp(token, "end") == 0) cout << endl; break; case MAXIMUM_DUMP_LEVEL: dumpFile << classPrefix << token << "PingPong(): numIteration(" << num << ")" << endl; if (strcmp(token, "end") == 0) dumpFile << endl; break; default: break; }} void Coclustering::checkDumpLevel4Coclustering(ostream &os, int num, double value){ os << endl; os << classPrefix << "Initialization Method = " << initialMethod[rowInitializationMethod] << " & " << initialMethod[colInitializationMethod] << endl; os << classPrefix << "Variation of Batch Update = " << batchUpdateType << endl; if (isTakingReverse) os << classPrefix << "# of Reversed Row(s) = " << numReversedRow << endl; os << classPrefix << "# of PingPong Iteration = " << num << endl; if (strcmp(classPrefix, ITCC_CLASS) == 0){ os << classPrefix << "Mutual Information(MI) of input Matrix = " << value << endl; os << classPrefix << "Final Objective Function Value (Loss in MI) = " << objValue << endl; } else if (strcmp(classPrefix, MSSRICC_CLASS) == 0){ os << classPrefix << "Squared Frobenius Norm of input Matrix = " << value << endl; os << classPrefix << "Final Objective Function Value (=||A-RR'ACC'||^2) = " << objValue << endl; } else if (strcmp(classPrefix, MSSRIICC_CLASS) == 0){ os << classPrefix << "Squared Frobenius Norm of input Matrix = " << value << endl; os << classPrefix << "Final Objective Function Value (=||A-RR'A-ACC'+RR'ACC'||) = " << objValue << endl; } else { os << "Invalid algorithm type in checkDumpLevel4Coclustering(): " << classPrefix << endl; exit(EXIT_FAILURE); } if (isComputingOneWayObjective){ os << classPrefix << "Final Obj.Func.Value of One-way Row Cluster = " << objValue4RowCluster << endl; os << classPrefix << "Final Obj.Func.Value of One-way Col Cluster = " << objValue4ColCluster << endl; } if (rowInitializationMethod == SEEDING_INIT) os << classPrefix << "Row seeding file = " << rowSeedingFilename << endl; if (colInitializationMethod == SEEDING_INIT) os << classPrefix << "Column seeding file = " << colSeedingFilename << endl; if (coclusterAccessMode != NO_OPEN_MODE) os << classPrefix << "Cocluster file = " << coclusterFilename << endl; if (dumpLevel == MAXIMUM_DUMP_LEVEL) os << classPrefix << "Dump file = " << dumpFilename << endl; if (objectiveAccessMode != NO_OPEN_MODE) os << classPrefix << "Objective file = " << objectiveFilename << endl; if (statisticsAccessMode != NO_OPEN_MODE) os << classPrefix << "Statistics file = " << statisticsFilename << endl;// os << endl;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -