使用svc.predict(x_test)输出所有“ 1”或“ 0”
我想获得正常的分类结果以保持程序运行
def svm_predict(x_data, y_data, Test_size, Random_state): #svm预测结果并返回一个不同核的最高值
y_data = np.ravel(y_data)
x_train, x_test, y_train, y_test = ts(x_data, y_data, test_size=Test_size, random_state=Random_state)
# kernel = 'rbf'
clf_rbf = svm.SVC(kernel='rbf', gamma='auto')
clf_rbf.fit(x_train, y_train)
y_rbf_predict = clf_rbf.predict(x_test)
score_rbf = roc_auc_score(y_test, y_rbf_predict)
# kernel = 'linear'
clf_linear = svm.SVC(kernel='linear', gamma='auto')
clf_linear.fit(x_train, y_train)
y_linear_predict = clf_linear.predict(x_test)
score_linear = roc_auc_score(y_test, y_linear_predict)
# kernel = 'poly'
clf_poly = svm.SVC(kernel='poly', gamma='auto')
clf_poly.fit(x_train, y_train)
y_ploy_predict = clf_poly.predict(x_test)
score_poly = roc_auc_score(y_test, y_ploy_predict)
return max(score_rbf, score_linear, score_poly)
答案 0 :(得分:0)
我不认为预测的结果应该用作roc_auc_score的参数,但是我不确定是否应该使用predict_proba或decision_function,这似乎还可以。另外,我看过你写的注释,我是中国人,我可以讨论