我有一个运行在Google Compute Engine上的python脚本,4个CPU 18gb RAM,但脚本在运行后被终止,我知道我正在加载大量数据,但我希望18gb的内存足够,有什么优化可以改进python来阻止Ubuntu杀死python脚本吗?
word_features = list(all_words.keys())[:15000]
testing_set = featuresets[10000:]
training_set = featuresets[:10000]
classifier = nltk.NaiveBayesClassifier.train(training_set)
print((nltk.classify.accuracy(classifier, testing_set))*100)
save_classifier = open("pickled/originalnaivebayes5k.pickle","wb")
pickle.dump(classifier, save_classifier)
save_classifier.close()
MNB_classifier = SklearnClassifier(MultinomialNB())
MNB_classifier.train(training_set)
print((nltk.classify.accuracy(MNB_classifier, testing_set))*100)
save_classifier = open("pickled/MNB_classifier5k.pickle","wb")
pickle.dump(MNB_classifier, save_classifier)
save_classifier.close()