naivebayes

naive bayes classifier dynamic training

做~自己de王妃 提交于 2021-02-05 07:43:17
问题 Is it possible (and how if it is) to dynamically train sklearn MultinomialNB Classifier? I would like to train(update) my spam classifier every time I feed an email in it. I want this (does not work): 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) to have similar result as this (works OK): x_train, x_test, y_train, y_test = tts(features, labels, test

R - Caret train() “Error: Stopping” with “Not all variable names used in object found in newdata”

寵の児 提交于 2021-01-28 07:13:02
问题 I am trying to build a simple Naive Bayes classifer for mushroom data. I want to use all of the variables as categorical predictors to predict if a mushroom is edible. I am using caret package. Here is my code in full: ################################################################################## # Prepare R and R Studio environment ################################################################################## # Clear the R studio console cat("\014") # Remove objects from environment