使用MLP的神经网络分类器

时间:2017-04-05 17:50:51

标签: python machine-learning neural-network

我是机器学习的新手,我正在使用python应用程序,该应用程序使用我将发布片段的数据集对扑克手进行分类。它似乎不太好用。它无法正确分类。我收到以下错误

", line 298, in fit
    raise ValueError("Multioutput target data is not supported with "
ValueError: Multioutput target data is not supported with label binarization

以下是我的代码:

import pandas as pnd
import numpy as np
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler
from sklearn.neural_network import MLPClassifier
from sklearn.metrics import classification_report
training = pnd.read_csv(".idea/train.csv")
training.keys()
training.shape
X = np.array(training)
y = np.array(training)
X_train, X_test, y_train, y_test = train_test_split(X, y)
scaler = StandardScaler()
# Fit only to the training data
scaler.fit(X_train)
X_train = scaler.transform(X_train)
X_test = scaler.transform(X_test)
mlp = MLPClassifier(hidden_layer_sizes=(30, 30, 30, 30, 30, 30, 30, 30, 30, 30))
mlp.fit(X_train, y_train)
predictions = mlp.predict(X_test)
print(classification_report(y_test, predictions))
len(mlp.coefs_)
len(mlp.coefs_[0])
len(mlp.intercepts_[0])

以下是我正在使用的数据集的示例: Image here

这是数据集的解释: https://archive.ics.uci.edu/ml/datasets/Poker+Hand

有什么问题吗?如果我能以正确的方式做事,我希望有人可以指导我。

1 个答案:

答案 0 :(得分:0)

只是为了在这里保留答案。

问题是scalet.fit必须包含Y_train

变化:

scaler.fit(X_train)

为:

scaler.fit(X_train, y_train)