At the moment I perform the following:
estimators = []
estimators.append(('standardize', StandardScaler()))
prepare_data = Pipeline(estimators)
n_splits = 5
tscv = TimeSeriesSplit(n_splits = n_splits)
for train_index, val_index in tscv.split(df_train):
X_train, X_val = prepare_data.fit_transform(df_train[train_index]), prepare_data.fit_transform(df_train[val_index])
X_test = prepare_data.fit_transform(df_test)
Now I would like to know if this is correct. My concern is that X_train
and X_test
are transformed separately. While in the first instance I thought this is how it should be I'm about to change my mind as I think I have to use the mean
and std
of the train set to use within the test set?