Rescaling multivariate time series data with sklearn

Viewed 104

I have a data set in (n, m) where n=128 samples and m=17 features. After windowing this data with a time lag of 3, I now have windowed data in (n-3, time_lag, m). The number of samples n is subtracted by three as demonstrated by the below table.

t  t-1  t-2  t-3
0  NAN  NAN  NAN
1  0    NAN  NAN
2  1    0    NAN

In my data processing pipeline, I scale the data first and then window it. If I use sklearn's MinMax scaler on the 2D data, how can I use that scaler to inverse transform the scaled 3D data?

A simple solution is shown below, but I am thinking I could use np.apply_along_axis or something similar for more speed.

for t in range(time_lag):
  windowed_data[:, t, :] = fitted_min_max_scaler.inverse_transform(windowed_data[:, t, :])

I know that I could just window the un-scaled data in (n, m), but I am interested specifically in the case of rescaling 3D data.

0 Answers
Related