2013-07-23 92 views
3

我使用內置的NLTK和訓練模型後SVM分類,當我嘗試將文檔進行分類,程序與Error during execution, QProcess error: 1 Execution InterruptedNLTK SVM分類終止

我使用下面的代碼終止: -

classifier = nltk.classify.svm.SvmClassifier.train(train_features) 
for test_record in test_data_list: 
    features = extract_features(test_record) 
    predict = classifier.classify(features) 
    print predict 

什麼可能是錯誤的原因?

回答

8

nltk.classify.svm已被棄用。對於分類支持向量機支持向量機基於 使用nltk.classify.scikitlearn (或scikit-learn直接)。對於更多的細節NLTK 3.0 documentation

您可以使用nltk.classify.scikitlearn如下

import nltk.classify 
from sklearn.svm import LinearSVC 

classifier = nltk.classify.SklearnClassifier(LinearSVC()) 
classifier.train(train_features) 

for test_record in test_data_list: 
    features = extract_features(test_record) 
    predict = classifier.classify(features) 
    print predict