x=dataset1[:,1:23] # features
y=dataset1[:,0] #classtypes
xtrain, xtest, ytrain, ytest = train_test_split(x, y, test_size=0.20)我的数据集只有字母。每行有23个字母。第一个字母是classtype,其他字母是feauter。我有两个班级--> a,z
示例: a,b,c,d,e,...,g
我将首先计算召回值、精确度和其他值。我需要找到ypred原因这些值要求2个参数(ytest,ypred)。如何使用朴素贝叶斯预测数据?
发布于 2018-05-22 17:04:55
我建议您看一下朴素贝叶斯分类器的sklearn文档:here
发布于 2018-05-22 23:24:48
既然您说您正在使用nltk库,那么您可以执行以下操作:
from nltk.classify import NaiveBayesClassifier
from nltk.classify.scikitlearn import SklearnClassifier
x=dataset1[:,1:23] # features
y=dataset1[:,0] #classtypes
xtrain, xtest, ytrain, ytest = train_test_split(x, y, test_size=0.20)
classifier = NaiveBayesClassifier.train(xtrain)
y_predicted = classifier.classify(xtest)这里,classify属性与scikit-learn算法中的predict属性相同。
可用的属性如下:

https://stackoverflow.com/questions/50462604
复制相似问题