def caculate_fitness(x_train, y_train, x_test, y_test): y_train = y_train.argmax(1) y_test = y_test.argmax(1) clf = svm_lpp().fit(x_train, y_train) y_test_score = clf.decision_function(x_test) #acc = accuracy_score(y_test, clf.predict(x_test)) #f1 = F1(y_test, clf.predict(x_test)) #acc = accuracy_score(y_test, clf.predict(x_test)) roc_auc = function_lpp_new.draw_roc(y_test, y_test_score) return roc_auc
def caculate_fitness_plot(x_train, y_train, x_test, y_test): y_train = y_train.argmax(1) y_test = y_test.argmax(1) clf = svm_lpp().fit(x_train, y_train) train_predict = clf.predict(x_train) test_predict = clf.predict(x_test) test_predict_proba = clf.decision_function(x_test) print(confusion_matrix(y_test, test_predict)) print('train sensitivity:', sensitivity(y_train, train_predict), 'train specifity:', specificity(y_train, train_predict)) print('test sensitivity:', sensitivity(y_test, test_predict), 'test specifity:', specificity(y_test, test_predict)) print('f1_score:', F1(y_test, test_predict)) print('acc:', accuracy_score(y_test, test_predict)) roc_auc = function_lpp_new.draw_roc(y_test, test_predict_proba) print('roc:', roc_auc) print('over')
x_train, x_test, index) result = obtain_flod_predict(x_train_pca, y_train, x_test_pca, y_test) save_true.append(result[0]) save_predict.append(result[1]) y_predict_label.append(result[2]) print(str(fold), 'over') for i in range(5): result_eva.append([ recall_score(save_true[i], y_predict_label[i]), specificity(save_true[i], y_predict_label[i]), precision_score(save_true[i], y_predict_label[i]), f1_score(save_true[i], y_predict_label[i]), accuracy_score(save_true[i], y_predict_label[i]), function_lpp_new.draw_roc(save_true[i], save_predict[i]) ]) for i in range(1, 5): save_true[0] = np.hstack([save_true[0], save_true[i]]) save_predict[0] = np.hstack([save_predict[0], save_predict[i]]) y_predict_label[0] = np.hstack( [y_predict_label[0], y_predict_label[i]]) save_true = save_true[0] save_predict = save_predict[0] y_predict_label = y_predict_label[0] scio.savemat( params['path_PCA'] + str(lll) + 'predict_genetic_multi.mat', { 'y_predict': save_predict, 'y_true': save_true