Neural Prophet for Time Series- A deep learning approach for sequential learning time-series data

 

Hello, hi there how are you doing today? i hope it's great.

In our previous articles, we have seen numerous ways to learn the sequential patterns hidden in our time series sequential data. But this time we will an approach to learning sequential data via Deep Learning using Forward Feed Neural Network. LSTM is also another deep learning approach but as we know it's not a forward-feed neural network it's a Recurrent Neural Network.

Forward Feed Neural Network

Forward Feed Neural network for time series we will call it as NeuralProphet the predecessor of Fbprophet from Facebook Data Science team.

It is relatively very few, here some of the few advantages over the Fbprophet

It's very easy to install pip install neuralprophet unlike in fbprophet there are a lot of dependencies specially pystan.

Model features

  • Gradient Descent for optimization via using PyTorch as the backend.
  • Autocorrelation modeling through AR-Net
  • Piecewise linear trend with optional automatic changepoint detection
  • Fourier term Seasonality at different periods such as yearly, daily, weekly, hourly.
  • Lagged regressors (measured features, e.g temperature sensor)
  • Future regressors (in advance known features, e.g. temperature forecast)
  • Country holidays & recurring special events
  • Sparsity of coefficients through regularization
  • Plotting for forecast components, model coefficients as well as final predictions
  • Automatic selection of training related hyperparameters
  • Support for panel data by building global forecasting models.

And just like before can handle missing values and outliers.

The next versions of NeuralProphet are expected to cover a set of new exciting features:

  • Logistic growth for trend component.
  • Uncertainty estimation of predicted values
  • Incorporate time series featurization for improved forecast accuracy.
  • Model bias modelling/correction with secondary model
  • Multimodal dynamics: unsupervised automatic modality-specific forecast.

Link to the NeuralProphet Repo: https://neuralprophet.com/html/index.html

So let’s try this new powerful approach

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
#Load the dataset
data = pd.read_csv("dataset.csv")
data.head(5)
#Selecting the important columns the date and the value
data = data[["Date","Close"]]

just like before in fbprophet we need to bring to the proper format

data = data.rename(columns = {"Date":"ds","Close":"y"}) 
data.head(5)

pip install neuralprophet #ignore if you have already installed

from neuralprophet import NeuralProphet
#model = NeuralProphet() #default model
model = NeuralProphet(growth='linear',
n_forecasts=60,
n_lags=60,
n_changepoints=50,
yearly_seasonality=True,
weekly_seasonality=False,
daily_seasonality=False,
batch_size=64,
epochs=100,
learning_rate=1.0,
impute_missing= "true",
normalize="auto",
)
metrics = model.fit(data,freq = "D")
#or
#metircs = model.fit(data,freq = "D", valid_p=0.30,epochs=100)
#-----------------------------------------------------------
#Fore more options
help(NeuralProphet)
class NeuralProphet(builtins.object)
| NeuralProphet(growth='linear', changepoints=None, n_changepoints=10, changepoints_range=0.9, trend_reg=0, trend_reg_threshold=False, yearly_seasonality='auto', weekly_seasonality='auto', daily_seasonality='auto', seasonality_mode='additive', seasonality_reg=0, n_forecasts=1, n_lags=0, num_hidden_layers=0, d_hidden=None, ar_sparsity=None, learning_rate=None, epochs=None, batch_size=None, loss_func='Huber', optimizer='AdamW', train_speed=None, normalize='auto', impute_missing=True)
|
| NeuralProphet forecaster.
|
| A simple yet powerful forecaster that models:
| Trend, seasonality, events, holidays, auto-regression, lagged covariates, and future-known regressors.
| Can be regualrized and configured to model nonlinear relationships.
|
| Methods defined here:
|
| __init__(self, growth='linear', changepoints=None, n_changepoints=10, changepoints_range=0.9, trend_reg=0, trend_reg_threshold=False, yearly_seasonality='auto', weekly_seasonality='auto', daily_seasonality='auto', seasonality_mode='additive', seasonality_reg=0, n_forecasts=1, n_lags=0, num_hidden_layers=0, d_hidden=None, ar_sparsity=None, learning_rate=None, epochs=None, batch_size=None, loss_func='Huber', optimizer='AdamW', train_speed=None, normalize='auto', impute_missing=True)
............................
model.fit()
model.fit()
metrics of neural prophet
metrics of NeuralProphet

So here it is, this is what we get.

Now to get the predictions

# Predictions
future = m.make_future_dataframe(data, periods=60, n_historic_predictions=len(data))
prediction = m.predict(future)

Same like before in fbprophet but here we need to define the n_historic_predictions and the periods ( the number of days we wanna predict)

NeuralProphet Output
NeuralProphet Output

Further just like before to get the components

m.plot_components(prediction)
plt.show()
NeuralProphet Components
NeuralProphet Components

“NeuralProphet is the new Facebook’s updated version of Prophet and allows users to use simple but powerful deep learning models such as AR-Net for forecasting tasks. What makes NeuralProphet unique is its ability to incorporate additional information such as trends, seasonality, and recurring events into account when generating forecasts and during fitting.”

The end of another interesting topic. No worries! we got more coming.

Likewise, if you like this article do visit my other articles and happy machine learning.

Next, we will look into how to impute missing values for Sequential time-series data using in…..te :)

Some of my alternative internet presences Facebook, Instagram, Udemy, Blogger, Issuu, and more.

Also available on Quora @ https://www.quora.com/profile/Rupak-Bob-Roy

Have a good day.

pexel


Comments

Popular Posts