ValueError:不允许使用y的混合类型

时间:2018-08-18 17:39:16

标签: python machine-learning scikit-learn bayesian-networks

我有彩票数据,我正在尝试以此进行预测。但是我坚持重塑数据。

我的数据的结构如下:

0,Week,Date,B1,B2,B3,B4,B5,B6
1,1140,15/08/2018,3,10,15,18,25,43
2,1139,11/08/2018,9,15,16,21,32,33
3,1139,11/08/2018,9,15,16,21,32,33 

我的Python代码:

dataset = pd.read_csv('son.csv')

# fit a Naive Bayes model to the data
model = GaussianNB()
y = dataset.values[:,9].reshape(1143,-1143)

X_train, X_test, y_train, y_test = train_test_split(dataset, y, test_size=0.2)
model.fit(X_train, y_train)
print(model)
# make predictions
expected = X_test
predicted = model.predict(y_test)
# summarize the fit of the model
print(metrics.classification_report(expected, predicted))
print(metrics.confusion_matrix(expected, predicted))

但是,我收到此错误:

  

ValueError:y的混合类型不允许,得到类型   {'multiclass-multioutput','binary'}错误。

我该如何解决?

1 个答案:

答案 0 :(得分:1)

以下错误 ValueError: Mix type of y not allowed 由于目标变量中存在不止一种类型的值(在您的情况下是多类和二进制),因此发生。请确保每个样本的目标数据集都包含相同类型的数据。

相关问题