Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NLTK SVM Classifier Terminates

I am using the SVM classifier built in NLTK and after training the model, when I try to classify a document, the program terminates with Error during execution, QProcess error: 1 Execution Interrupted

I am using the following code:-

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

What could be the reason for the error?

like image 788
Jasneet Avatar asked Jul 27 '26 16:07

Jasneet


1 Answers

nltk.classify.svm was deprecated. For classification based on support vector machines SVMs use nltk.classify.scikitlearn (or scikit-learn directly).For more details NLTK 3.0 documentation

You can use nltk.classify.scikitlearn as follows

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
like image 192
abilng Avatar answered Jul 30 '26 05:07

abilng



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!