1
$\begingroup$

I'm trying to solve a time series forecasting problem, specifically I want to use historical data with an aspect of COVID-19 impact on global and regional aviation, number of new COVID-19 cases per country of origin (country of registration for the aircraft), and monthly average temperature in said country.

I wanted to ask for input on a tool that blends support datasets with a historical time series well? Ideally, the average temperature and 2-4 week lag of COVID-19 cases in a country would be input to the model along with each aircraft 12-24 month history.

I'm specifically looking at Tensorflow Probability and their Structural Time Series: https://blog.tensorflow.org/2019/03/structural-time-series-modeling-in.html and https://www.tensorflow.org/probability/examples/Structural_Time_Series_Modeling_Case_Studies_Atmospheric_CO2_and_Electricity_Demand#model_and_fitting

SK Time could also be an option: https://www.sktime.org/en/latest/examples/01_forecasting.html#Detrending

Facebook's Prophet also seems to be able to model this: https://facebook.github.io/prophet/docs/seasonality,_holiday_effects,_and_regressors.html#seasonalities-that-depend-on-other-factors

It could probably also be seen as a regression problem, by engineering features of all the time series datasets and feeding it into a regression model to predict monthly flights?

Anyway, I'm asking this question looking for some inspiration and possibly a tool that I haven't seen before could provide other options.

$\endgroup$

1 Answer 1

1
$\begingroup$

I'll go ahead and plug something I have been messing around with I am calling LazyProphet . Definitely takes a lot of influence from fbprophet but it measures trend via binary segmented regressions then measures seasonality then exogenous factors then uses gradient boosting to create more splits of the trend and regularize/adjust the other coefficients. It boosts until the global cost function (controlled via the regularization parameter) stops decreasing. One nice thing it has over fbprophet (I think, pretty sure prophet doesnt have this) is trend dampening on your forecasted trend which can be controlled via a parameter. Also you have a few different estimators for trend such as a mean changepoint/ linear changepoint/ global polynomial ridge regression. There are some examples in the readme in the link!

Like I said this was mostly me just messing around and adding stuff so it is quite messy code wise but is is pip installable and the class object is easy enough to work with. I do have a much cleaner implementation coming sometime soon with a lot more trend/seasonal estimators since the procedure itself is quite general and can work with an ARIMA or ETS or whatever measure of trend.

As a quick example of something you are interested in (although this is a dumb example in regards to our variables, just using what is easy):

import quandl
import pandas as pd
import matplotlib.pyplot as plt
import LazyProphet as lp

#Get bitcoin data
data = quandl.get("BITSTAMP/USD")
#let's get our X matrix with the new variables to use
X = data.drop('Low', axis = 1)
X_train = X.iloc[-930:-50,:]
X_test = X.iloc[-50:,:]
y = data['Low']
y_train = y[-930:-50,]
y_test = y[-50:,]

#create Lazy Prophet class
boosted_model = lp.LazyProphet(freq = 365, 
                            estimator = 'mean', 
                            max_boosting_rounds = 200,
                            approximate_splits = True,
                            regularization = 1.2,
                            verbose = 1,
                            exogenous = X_train)
#Fits on just the time series
#returns a dictionary with the decomposition
output = boosted_model.fit(y_train)
forecast = boosted_model.extrapolate(len(y_test), X_test)
plt.plot(np.append(output['yhat'].values, forecast), label = 'Predicted')
plt.plot(np.append(y_train.values,y_test.values), label = 'Actual')
plt.vlines(len(X_train), 0, 13000, linestyles='dashed', color = 'red')
plt.legend()
plt.show()

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.