Univariate forecasting with a feedforward neural network
This recipe walks you through the process of building a feedforward neural network for forecasting with univariate time series.
Getting ready
Having transformed the time series data into an appropriate format for supervised learning, we are now ready to employ it for training a feedforward neural network. We strategically decided to resample the dataset, transitioning from hourly to daily data. This optimization significantly accelerates our training processes:
series = series.resample('D').sum()
How to do it…
Here are the steps for building and evaluting a feedforward neural network using PyTorch:
- We begin by splitting the data into training and testing and normalizing them. It’s important to note that the scaler should be fitted on the training set and used to transform both the training and test sets:
import pandas as pd from sklearn.model_selection import train_test_split from...