Beispiel #1
0
SVM = LogisticRegression(penalty='l2', C=0.1)
# SVM = GradientBoostingClassifier(random_state=6)
SVM.fit(train_data_x, train_data_y)

# test_data_x = train_data_x
# test_y_1D = train_data_y

y_pred = SVM.predict(test_data_x)  #得到输出标签值
accuracy = SVM.score(test_data_x, test_y_1D)  #得到分类正确率
y_probability = SVM.predict_proba(test_data_x)  #得到分类概率值
y_probability_first = [x[1] for x in y_probability]

test_auc = metrics.roc_auc_score(test_y_1D, y_probability_first)
kappa = evaluate_method.get_kappa(test_y_1D, y_probability_first)
IOA = evaluate_method.get_IOA(test_y_1D, y_probability_first)
MCC = evaluate_method.get_mcc(test_y_1D, y_probability_first)
recall = evaluate_method.get_recall(test_y_1D, y_probability_first)
precision = evaluate_method.get_precision(test_y_1D, y_probability_first)
f1 = evaluate_method.get_f1(test_y_1D, y_probability_first)
# MAPE = evaluate_method.get_MAPE(test_y_1D,y_probability_first)

# evaluate_method.get_ROC(test_y_1D,y_probability_first,save_path='roc_lr_test.txt')

print("ACC = " + str(accuracy))
print("AUC = " + str(test_auc))
print(' kappa = ' + str(kappa))
print("IOA = " + str(IOA))
print("MCC = " + str(MCC))
print(' precision = ' + str(precision))
print("recall = " + str(recall))
print("f1 = " + str(f1))
Beispiel #2
0
# test_data_x,test_data_y = train_data_x,train_data_y
# train_data_x = mean_data(train_data_x)
# train_data_x = np.array(train_data_x)

model.fit(train_data_x, train_data_y)

# test_data_x =train_data_x
# test_data_y = train_data_y
# y_pred = model.predict(data_input_x)
accuracy = model.score(test_data_x, test_data_y)
y_probability = model.predict_proba(test_data_x)
y_probability_first = [x[1] for x in y_probability]
print(y_probability_first)
test_auc = metrics.roc_auc_score(test_data_y, y_probability_first)
kappa = evaluate_method.get_kappa(test_data_y, y_probability_first)
mcc = evaluate_method.get_mcc(test_data_y, y_probability_first)
# get_ROC(test_data_y, y_probability_first, 'SVM_roc.txt')

print('accuracy = %f' % accuracy)
print('AUC = %f' % test_auc)
print(kappa)
print(mcc)

# print (confusion_matrix(data_input_y,y_pred))

# total_data_x = readTotalData(total_data_file='total_data_yushan0.csv',num_factors=16)
# # total_data_x = mean_data(total_data_x)
# # total_data_x = np.array(total_data_x)
# y_probability_total = model.predict_proba(total_data_x)
# y_probability_total_first = [x[1] for x in y_probability_total]
# with open('result_svm0.txt','w') as file: