Shl*_*rtz 10 python csv machine-learning pandas keras
我正在尝试根据我的数据集中的部分特征训练Keras模型.我已经加载了数据集并提取了这样的功能:
train_data = pd.read_csv('../input/data.csv')
X = train_data.iloc[:, 0:30]
Y = train_data.iloc[:,30]
# Code for selecting the important features automatically (removed) ...
# Selectintg important features 14,17,12,11,10,16,18,4,9,3
X = train_data.reindex(columns=['V14','V17','V12','V11','V10','V16','V18','V4','V9','V3'])
print(X.shape[1]) # -> 10
Run Code Online (Sandbox Code Playgroud)
但是当我调用fit方法时:
# Fit the model
history = model.fit(X, Y, validation_split=0.33, epochs=10, batch_size=10, verbose=0, callbacks=[early_stop])
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
KeyError: '[3 2 5 1 0 4] not in index'
Run Code Online (Sandbox Code Playgroud)
我错过了什么?
Mar*_*jko 11
keras
期望模型输入是numpy
数组 - 而不是pandas.DataFrame
s.尝试:
X = train_data.iloc[:, 0:30].as_matrix()
Y = train_data.iloc[:,30].as_matrix()
Run Code Online (Sandbox Code Playgroud)
随着as_matrix
方法转换pandas.DataFrame
为numpy.array
.
归档时间: |
|
查看次数: |
3155 次 |
最近记录: |