ML之NB:基于NB朴素贝叶斯算法训练20类新闻文本数据集进行多分类预测
作者:互联网
ML之NB:基于NB朴素贝叶斯算法训练20类新闻文本数据集进行多分类预测
输出结果
设计思路
核心代码
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))
标签:20,predict,ML,NB,train,vec,test,mnb 来源: https://blog.csdn.net/qq_24624539/article/details/87899451