BaşlayınÜcretsiz Başlayın

Engineering multiple rolling features at once

Now that you've practiced some simple feature engineering, let's move on to something more complex. You'll calculate a collection of features for your time series data and visualize what they look like over time. This process resembles how many other time series models operate.

Bu egzersiz

Machine Learning for Time Series Data in Python

kursunun bir parçasıdır
Kursu Görüntüle

Egzersiz talimatları

  • Define a list consisting of four features you will calculate: the minimum, maximum, mean, and standard deviation (in that order).
  • Using the rolling window (prices_perc_rolling) we defined for you, calculate the features from features_to_calculate.
  • Plot the results over time, along with the original time series using the given code.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

# Define a rolling window with Pandas, excluding the right-most datapoint of the window
prices_perc_rolling = prices_perc.rolling(20, min_periods=5, closed='right')

# Define the features you'll calculate for each window
features_to_calculate = [np.min, ____, ____, ____]

# Calculate these features for your rolling window object
features = prices_perc_rolling.____(features_to_calculate)

# Plot the results
ax = features.loc[:"2011-01"].plot()
prices_perc.loc[:"2011-01"].plot(ax=ax, color='k', alpha=.2, lw=3)
ax.legend(loc=(1.01, .6))
plt.show()
Kodu Düzenle ve Çalıştır