多项式拟合方法在传递两个系列变量时,给了我“用序列设置数组元素”

2024-10-04 03:16:34 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在做一个朴素贝叶斯分类,使用多项式NB拟合方法,并向其传递两个变量,即熊猫系列,如何将熊猫系列转换为sklearn多项式NB需要的适当类型

这是我的python代码:

x = ConcatenateWordsSentiments['text']
y = ConcatenateWordsSentiments['label']

from sklearn.model_selection import train_test_split
#split train / test
X_train, X_test, y_train, y_test = train_test_split(xtrain, ytrain, 
test_size=0.33, random_state=42)


from sklearn.naive_bayes import MultinomialNB

nb = MultinomialNB()
nb.fit(X_train, y_train)

这里的x,y,x_火车和y_火车是熊猫系列


Tags: 方法代码fromtestimport类型分类train