简体   繁体   English

使用MLP的神经网络分类器

[英]Neural network classifier using MLP

I'm new to Machine Learning and I'm working on a python application that classifies an poker hands using a dataset which II will post snippets. 我是机器学习的新手,我正在研究一个python应用程序,该应用程序使用II将发布摘要的数据集对扑克手进行分类。 It does not seem to work well. 它似乎运行不佳。 It cannot classify the hands correctly. 它无法正确分类手。 And I am getting the following error 我收到以下错误

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

the following is my code: 以下是我的代码:

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])

The following is a sample of the data set I am using: Image here 以下是我正在使用的数据集的示例: 此处的图像

And here is a desciption of the data set: https://archive.ics.uci.edu/ml/datasets/Poker+Hand 这是数据集的描述: https : //archive.ics.uci.edu/ml/datasets/Poker+Hand

Is there something wrong? 有什么不对? I do hope someone could guide me if I'm doing things the right way. 我确实希望有人以正确的方式指导我。

Just to keep it as an answer here. 只是为了在这里保留答案。

The problem is that scalet.fit has to contain Y_train . 问题是scalet.fit必须包含Y_train

Change: 更改:

scaler.fit(X_train)

to: 至:

scaler.fit(X_train, y_train)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM