I shortly started with Python, Pandas, Numpy, etc. for my master thesis. It concerns about time series (sensor) data to be fed into an LSTM (multi-class classification problem). The current dataset represents a dataframe with 32 features (columns).
My goal: I want to verify the influence of moving windows and other methods on the LSTM's model performance. For this I already implemented a moving window method (median) with a size of 10 and exponential smoothing on the whole trace:
#Window size: 10
df_Median = df.rolling(10).median()
#application on whole trace
df_EWM_mean = df.ewm(alpha=0.2).mean()
My challenge: The third method should be a moving window with a gaussian shape (Gauss kernel). I implemented it according to the Pandas documentation: Pandas.DataFrame.rolling
for header, content in df.iteritems():
stdDev = np.std(content)
if stdDev != 0:
win_len = 10
df_Gauss = df.loc[:,header].rolling(win_len, win_type='gaussian').mean(std=stdDev)
This actually works. But the Standard Deviation argument stdDev must be calculated by the 10 current data points within the window, not from the whole trace... So I'd have to select the 10 current data points, calculate the stdDev, hand it over to the function, shift the window 10 points to the right and start from beginning...
How could this be accomplished? I'm quite new to Python, Pandas etc. So I'd be very grateful for hints.
Many thanks in advance.