2017-04-05 169 views
1

我是機器學習的新手,我正在研究一個使用數據集分類撲克手的python應用程序,我將發佈片段。它似乎不工作。它無法正確分類。而且我收到以下錯誤使用MLP的神經網絡分類器

", 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

有什麼錯嗎?如果我以正確的方式做事,我希望有人能指導我。

+0

會發生什麼(X_train)到scaler.fit(X_train,y_train)? – BernardoGO

+0

mlp.fit(X_train,y_train)raise ValueError(「多輸出目標數據不受支持」 ValueError:多輸出目標數據不支持標籤二值化 仍然收到相同的錯誤 – Ozzman1893

回答

0

只是爲了讓它在這裏作爲答案。

問題是scalet.fit必須包含Y_train

變化:

scaler.fit(X_train) 

到:如果你改變scaler.fit

scaler.fit(X_train, y_train)