ML之NB:基于NB樸素貝葉斯算法訓(xùn)練20類新聞文本數(shù)據(jù)集進(jìn)行多分類預(yù)測(cè)
vec = CountVectorizer()
X_train = vec.fit_transform(X_train)
X_test = vec.transform(X_test)
mnb = MultinomialNB()
mnb.fit(X_train, y_train)
y_predict = mnb.predict(X_test)
print('The accuracy of Naive Bayes Classifier is', mnb.score(X_test, y_test))
聯(lián)系客服