Get startedGet started for free

Transforming backtesting output

Once backtesting is complete, you will need to transform the data in order to effectively evaluate the results and choose the best-performing model.

This exercise is part of the course

Designing Forecasting Pipelines for Production

View Course

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

models = list(ml_models.keys())  

bkt_long = pd.melt(
    bkt_df,
    id_vars=["unique_id", "ds", "cutoff", "y"],
  	# Complete two f-strings
    value_vars=models + [f"{____}-lo-95" for model in models] + [f"{____}-hi-95" for model in models],
    var_name="model_label", 
    value_name="value")

print(bkt_long.head())
Edit and Run Code