a2rl.utils.backtest#
- a2rl.utils.backtest(df, simulator, start_row=0, context_rows=2, predict_rows=3, return_groudtruth=False)[source]#
Utility to perform backtesting on simulator.
By using groundtruth dataset
df
, takecontext_rows
number of rows as context, and groundtruth action, predict the next states(s1,s2...)
and rewards(r,v)
. Then append the predicted next states and rewards as new context, and repeat the steps again until we getpredict_rows
number of new rows.- Parameters:
df (
WiDataFrame
) – WiDataFrame, this is the original dataframe before tokenized.simulator (
Simulator
) – Pretrain whatif Simulator.start_row (
int
) – The dataframe starting row index for backtestcontext_rows (
int
) – Number of dataframe rows to be used as context, starting fromstart_row
.predict_rows (
int
) – Number of dataframe rows to predict.return_groudtruth (
bool
) – Return groundtruth dataframe for comparison when true.
- Return type:
- Returns:
Simulated Dataframe.