是否有可能(以及如何)动态训练 sklearn MultinomialNB 分类器?每次我在其中输入电子邮件时,我都想训练(更新)我的垃圾邮件分类器。
我想要这个(不起作用):
x_train, x_test, y_train, y_test = tts(features, labels, test_size=0.2)
clf = MultinomialNB()
for i in range(len(x_train)):
clf.fit([x_train[i]], [y_train[i]])
preds = clf.predict(x_test)
得到与此类似的结果(工作正常):
x_train, x_test, y_train, y_test = tts(features, labels, test_size=0.2)
clf = MultinomialNB()
clf.fit(x_train, y_train)
preds = clf.predict(x_test)