[英]Why accuracy doesn't get printed?
因此,以下代碼永遠不會顯示准確性。
1 #!/usr/bin/python
2
3 """.
4 This is the code to accompany the Lesson 2 (SVM) mini-project.
5
6 Use a SVM to identify emails from the Enron corpus by their authors:....
7 Sara has label 0
8 Chris has label 1
9 """
10 ....
11 import sys
12 from time import time
13 sys.path.append("../tools/")
14 from email_preprocess import preprocess
15 from sklearn import svm
16 from sklearn.metrics import accuracy_score
17
18
19 ### features_train and features_test are the features for the training
20 ### and testing datasets, respectively
21 ### labels_train and labels_test are the corresponding item labels
22 features_train, features_test, labels_train, labels_test = preprocess()
23 clf=svm.SVC(kernel='linear')
24 clf.fit(features_train, labels_train)
25 pred=clf.predict(features_test)
26 print(accuracy_score(labels_test, pred))
我試圖找出為什么行print(accuracy_score(labels_test, pred))
根本不打印任何內容。 它應該打印一些值。 可能是什么問題?
我添加了這一行代碼,使其能夠打印出一些東西。 我見過人們通常使用1000次迭代:
clf=svm.SVC(kernel='linear',max_iter=100)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.