Stock-Prediction-Models
Stock-Prediction-Models copied to clipboard
⚠️ Data Leakage: Must not use test data when fitting MinMaxScaler()
trafficstars
Probably, I found a serious error.
If I'm correct, we cannot use any information from test data when preprocessing data.
However, your code applied fit_transform() to train and test data.
This means train data can contain information from test data and effects accuracy.
Please correct me if my idea is wrong, thank you.
This answer seems working well for this issue.
https://stackoverflow.com/questions/70923839/sklearn-preprocessing-with-a-rolling-window
Probably, also we have to care about stationarity, when we treat time series data