简体   繁体   中英

Loading Iris data into MLPClassifier

I am attempting to load url = "https://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data and split this file in Jupyter but continue to get multiple errors. I am new to programing and in desperate need of assistance. I have spent numerous hours on attempting to rectify the errors. Error messages: "indexing.py in __getitem__(self, key)", "raise TypeError("Cannot index by location index with a non-integer key")" TypeError: Cannot index by location index with a non-integer key I am also attempting to split the data into test and training.

from sklearn.model_selection import train_test_split 
X_train, X_test, y_train, y_test = train_test_split(['data'], ['target'], random_state=0)

Assistance in requested.

import pandas as pd
from sklearn import preprocessing
#from sklearn.preprocessing import StandardScaler
from sklearn.neural_network import MLPClassifier
from sklearn.model_selection import train_test_split 
X_train, X_test, y_train, y_test = train_test_split(['data'], ['target'], random_state=0)

You can load directly the iris data from sklearn:

from sklearn.datasets import load_iris
data = load_iris()

Then split:

from sklearn.cross_validation import train_test_split
X_train,X_test,y_train,y_test=train_test_split(data.data,data.target,test_size=0.5)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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