我在正确分割数据集序列和数据集测试时遇到问题。
data = pd.read_csv(".../all_data.csv", header='infer')
data = data.drop(['^GSPC'], 1)
data = data.drop(['DATE'], 1)
n = data.shape[0]
data_train = data[:603]
data_test = data[603:]
这是我对数据进行切片的方法,然后在创建模型后,按如下所示尝试示例批处理
example_batch = normed_data_train[:10]
print(example_batch)
example_result = nn.predict(example_batch)
示例批量打印:
AAL AAP AAPL ... ZBH ZION ZTS
0 -0.538021 0.647482 -1.057912 ... -1.648370 -1.206065 -0.947623
1 -0.593968 0.608053 -1.140970 ... -1.422345 -1.232422 -0.890197
2 -0.492114 0.456404 -1.204207 ... -1.374370 -1.302404 -0.889421
3 -0.604012 0.518201 -1.337917 ... -1.630246 -1.372386 -1.002721
4 -0.615488 0.394229 -1.321872 ... -1.676088 -1.397835 -1.055491
5 -0.513633 0.450718 -1.272478 ... -1.862664 -1.442369 -1.156376
6 -0.381652 0.489388 -1.227488 ... -1.535356 -1.451457 -1.126109
7 -0.654221 0.265328 -1.308343 ... -1.713406 -1.553249 -1.259587
8 -0.589665 0.233482 -1.241331 ... -1.553482 -1.544161 -1.191297
9 -0.846455 0.346080 -1.316523 ... -1.726198 -1.603237 -1.249499
但是,在所述批处理上运行nn.predict会出现以下错误:
KeyError: "None of [Int64Index([0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
dtype='int64')] are in the [columns]"
我尝试了各种方法来改变切片数据的方式,包括iloc和loc方法。
请帮助。