热线电话:13121318867

登录
2020-03-01 阅读量: 734
python报错

报错:unsupported operand type(s) for +:'int' and 'str'

因为kernel里有整型也有字符型,所以无法遍历,正确代码为:

kernel = ['linear', 'poly', 'rbf', 'sigmoid']

for i in kernel:

start_time = time.time()

clf = SVC(kernel = i, gamma = 'auto', degree = 1, class_weight = 'balanced').fit(Xtrain, ytrain)

score = clf.score(Xtest, ytest)

recall = recall_score(ytest, clf.predict(Xtest))

auc = roc_auc_score(ytest, clf.predict(Xtest))

end_time = time.time()

print('current kernel is {}, period:{}, score:{}, recall:{}, auc:{}'.format(i,

end_time - start_time,

score,

recall,

auc

))

0.0000
2
关注作者
收藏
评论(0)

发表评论

暂无数据
推荐帖子