训练Keras模型并在validation_split=0.2
函数中使用fit()
之后,我们如何将那20%的旧数据帧转换为新数据帧进行测试?
#train model
model.fit(train_X, train_y, validation_split=0.2, epochs=30, callbacks=[early_stopping_monitor])
答案 0 :(得分:0)
实际上,当您将validation_split
参数设置为x
时,会发生的情况是训练样本的最后x
%被视为验证数据。因此,如果您想获得训练期间使用的相同验证数据,则可以像这样对数据框进行切片:
idx = int(len(train_X) * 0.2) # 0.2 is the value of validation split
# if train_X and train_y are numpy arrays
val_X = train_X[idx:]
val_y = train_y[idx:]
# if train_X and train_y are pandas dataframes
val_X = train_X.iloc[idx:]
val_y = train_y.iloc[idx:]