我正在使用分类报告来检查准确性以及混淆矩阵
答案 0 :(得分:0)
我对代码做了一些修改,现在看来可以了
x = np.array([17, 17.083333, 17.166667, 17.25, 17.333333, 17.416667])
x = x.reshape(6,1)
y = [1,0,1,1,0,1]
X_train, X_test, y_train, y_test = train_test_split(x, y, test_size = 0.20)
clf = svm.SVC(kernel='linear')
clf.fit(X_train,y_train)
pred = clf.predict(X_test)
score= sk.metrics.accuracy_score(y_test,pred)
report = sk.metrics.classification_report (y_test, pred, target_names = ['0','1'])
confusionmatrix = sk.metrics.confusion_matrix(y_test,pred)
print ("Accuracy_Score: "+str(score))
print ("Classification_Report:\n"+report)
print ("Confusion_Matrix:")
print (confusionmatrix)
输出:
Accuracy_Score:0.5
分类报告:
精确召回f1得分支持
0 0.00 0.00 0.00 1
1 0.50 1.00 0.67 1
平均/总计0.25 0.50 0.33 2
Confusion_Matrix:
[[0 1]
[0 1]]
我将输入“ x”更改为一个numpy数组,并从x.reshape中删除了值,并且您在clf.predict()中输入了“ Xtest”,也必须输入“ X_test”。
希望这会有所帮助