/************* SVM specific functions **********/ matrix * SVMpopulateAccuracyMatrix(matrix * predictions, matrix * metadata, struct slInt * trainingList) { int i, j; //make a place to store results matrix * result = init_matrix(2, metadata->cols); safef(result->rowLabels[0], MAX_LABEL, "trainingAccuracies"); safef(result->rowLabels[1], MAX_LABEL, "testingAccuracies"); for(i = 0; i < metadata->cols; i++) safef(result->colLabels[i], MAX_LABEL, "%s", metadata->colLabels[i]); result->labels=1; //iterate over each sample, recording accuacies struct slInt * testList = index_complement(metadata->cols,trainingList); for(j = 0; j < predictions->cols; j++) { int resultRow = -1; if(indexInList(j, trainingList)) resultRow = 0; else if(indexInList(j, testList)) resultRow = 1; if(metadata->graph[0][j] == NULL_FLAG) result->graph[resultRow][j] = NULL_FLAG; // O_o else if((metadata->graph[0][j] == 0 && predictions->graph[0][j] < 0) || (metadata->graph[0][j] == 1 && predictions->graph[0][j] > 0)) result->graph[resultRow][j] = 1; //yay! else result->graph[resultRow][j] = 0; //boo. } return result; }
void SelectGraphicsWidget::ok() { int comboBoxIndex = ui.comboBox->currentIndex(); QListWidgetItem* currentItem = ui.listWidget->currentItem(); if (!currentItem) { QMessageBox::critical(this,QStringLiteral("请选择交通图"),QStringLiteral("您尚未选择交通图")); return ; } QStringList tmpList; switch (comboBoxIndex) { case 0: { tmpList = mList0; break; } case 1: { tmpList = mList1; break; } case 2: { tmpList = mList2; break; } case 3: { tmpList = mList3; break; } default: break; } int listIndex = indexInList(currentItem->text(),tmpList); close(); emit selectGraphics(comboBoxIndex,listIndex); }