关键错误,但不确定原因

时间:2018-03-25 18:24:07

标签: python

我正在使用Pima Indian Dataset,我收到了一个错误。这是代码:

import numpy
import pandas
import sklearn
from sklearn import preprocessing
from sklearn.preprocessing import MinMaxScaler
from sklearn.neighbors import NearestNeighbors
from sklearn.cross_validation import train_test_split

csvfile = open("diabetes.csv", 'r')
diabetes = pandas.read_csv(csvfile)

min_max_scaler = preprocessing.MinMaxScaler()
diabetes_scaled = min_max_scaler.fit_transform(diabetes)
diabetes_normalized = pandas.DataFrame(diabetes_scaled, columns=diabetes.columns)

X = diabetes_normalized['Pregnancies', 'Glucose', 'BloodPressure', 'SkinThickness', 'Insulin', 'BMI', 'DiabetesPedigreeFunction', 'Age']

我得到了最后一行的关键错误,但不知道为什么。

1 个答案:

答案 0 :(得分:1)

传递列名列表,以便从dataframe中选择多个列,如下所示:

'

而不是

$post->share_tw = isset($request->share_tw) ? 1 : 0;
$post->share_ins = isset($request->share_ins) ? 1 : 0;