Why is the "target" shifted -1?

Course Name: Machine Learning for Options Trading, Section No: 4, Unit No: 7, Unit type: Notebook



=> in Define the Target Value

Create the target variable

spy['return'] = spy.Close.pct_change(1).shift(-1)



The pct change is already the previos day - actual day  => the shift of additional -1 will give the future value to the ml ?

 

Hey Oliver,



By shifting the target variable by -1, you align it with the corresponding input data. This means that for each row in your dataset, the target variable represents what will happen on the next day based on the data available up to the current day.



Hope this helps!



Thanks

Rushda