Package: neuralforecast
NixtlaNeural 🧠 ForecastUser friendly state-of-the-art neural forecasting models.NeuralForecastoffers a large collection of neural forecasting models focused on their usability, and robustness. The models range from classic networks likeMLP,RNNs to novel proven contributions likeNBEATS,TFTand other architectures.💻 InstallationPyPIYou can installNeuralForecast'sreleased versionfrom the Python package indexpipwith:pipinstallneuralforecast(Installing inside a python virtualenvironment or a conda environment is recommended.)CondaAlso you can installNeuralForecast'sreleased versionfromcondawith:condainstall-cconda-forgeneuralforecast(Installing inside a python virtual environment or a conda environment is recommended.)Dev ModeIf you want to make some modifications to the code and see the effects in real time (without reinstalling), follow the steps below:gitclonehttps://github.com/Nixtla/neuralforecast.gitcdneuralforecast
pipinstall-e.🏃🏻‍♀️🏃 Getting StartedTo get started follow thisguide, where we exploreNBEATS, extend it towards probabilistic predictions and exogenous variables.Or follow this simple example where we train theNBEATSmodel and predict the classic Box-Jenkins air passengers dataset.importnumpyasnpimportpandasaspdfromIPython.displayimportdisplay,Markdownimportmatplotlib.pyplotaspltfromneuralforecastimportNeuralForecastfromneuralforecast.modelsimportNBEATS,NHITSfromneuralforecast.utilsimportAirPassengersDF# Split data and declare panel datasetY_df=AirPassengersDFY_train_df=Y_df[Y_df.ds<='1959-12-31']# 132 trainY_test_df=Y_df[Y_df.ds>'1959-12-31']# 12 test# Fit and predict with NBEATS and NHITS modelshorizon=len(Y_test_df)models=[NBEATS(input_size=2*horizon,h=horizon,max_steps=50),NHITS(input_size=2*horizon,h=horizon,max_steps=50)]nf=NeuralForecast(models=models,freq='M')nf.fit(df=Y_train_df)Y_hat_df=nf.predict().reset_index()# Plot predictionsfig,ax=plt.subplots(1,1,figsize=(20,7))Y_hat_df=Y_test_df.merge(Y_hat_df,how='left',on=['unique_id','ds'])plot_df=pd.concat([Y_train_df,Y_hat_df]).set_index('ds')plot_df[['y','NBEATS','NHITS']].plot(ax=ax,linewidth=2)ax.set_title('AirPassengers Forecast',fontsize=22)ax.set_ylabel('Monthly Passengers',fontsize=20)ax.set_xlabel('Timestamp [t]',fontsize=20)ax.legend(prop={'size':15})ax.grid()🎉 New!Quick Start: Minimal usage example of the NeuralForecast library on Box's AirPassengers Data.Multi Quantile NBEATS Example: Produce accurate and efficient probabilistic forecasts in long-horizon settings. Outperforming AutoARIMA's accuracy in a fraction of the time.Long Horizon NHITS Example:  Load, train, and tune hyperparameters, to achieve Long-Horizon SoTA. Outperform Award Winning Transformers by 25% in 50x less time.Hierarchical Forecasting HINT Example:  Obtain accurate probabilistic coherent predictions for hierarchical datasets.🔥  HighlightsUnifiedStatsForecastinterfaceNeuralForecast().fit(Y_df).predict(h=7).Industry/Competition provenESRNN,NBEATS, andTFTimplementations.Improve accuracy and speed over classicARIMA/ETSin two lines of code. Check the experimentshere.Predict Series with little to no history, using Transfer learning. Check the experimentshere.🎊 FeaturesExogenous Variables: Static, lagged and future exogenous support.Forecast Interpretability: Plot trend, seasonality and exogenousNBEATS,NHITS,TFT,ESRNNprediction components.Probabilistic Forecasting: Simple model adapters for quantile losses and parametric distributions.Train and Evaluation LossesScale-dependent, percentage and scale independent errors, and parametric likelihoods.Automatic Model SelectionParallelized automatic hyperparameter tuning, that efficiently searches best validation configuration.Simple InterfaceUnified SKLearn Interface forStatsForecastandMLForecastcompatibility.Model Collection: Out of the box implementation ofMLP,LSTM,RNN,TCN,DilatedRNN,NBEATS,NHITS,ESRNN,TFT,Informer,PatchTSTandHINT. See the entirecollection here.Missing something? Please open an issue or write us in📖 Why?There is a shared belief in Neural forecasting methods' capacity to improve our pipeline's accuracy and efficiency.Unfortunately, available implementations and published research are yet to realize neural networks' potential. They are hard to use and continuously fail to improve over statistical methods while being computationally prohibitive. For this reason, we createdNeuralForecast, a library favoring proven accurate and efficient models focusing on their usability.🔬 Accuracy & ⏲ SpeedIndustry/Competition Proven MethodsAn extensive empirical evaluation is critical to generate confidence and promote the adoption and development of novel methods. For this reason, we replicate and verify the results of our implementation of the following industry/competition-proven methods:ESRNN,NBEATS,NHITS, andTFT. If you are interested in reproducing the results, check the experimentshere.Simple and Efficient Method's ComparisonLikecore.StatsForecast, thecore.NeuralForecastwrapper class allows us to easily compare any model in the collection to select or ensemble the best performing methods. Aditionally it offers a high-end interface that operates with (potentially large) sets of time series data stored in pandas DataFrames. Thecore.NeuralForecastefficiently parallelizes computation across GPU resources. Check the experimentshere.📖 Documentation (WIP)Thedocumentation pagecontains the models' code documentation, methods, utils, and other tutorials. Docstrings accompany most code.🔨 How to contributeIf you wish to contribute to the project, please refer to ourcontribution guidelines.📚 ReferencesThis work is highly influenced by the fantastic work of previous contributors and other scholars on the neural forecasting methods presented here. We want to highlight the work ofBoris Oreshkin,Slawek Smyl,Bryan Lim, andDavid Salinas. We refer toBenidis et al.for a comprehensive survey of neural forecasting methods.Contributors ✨Thanks goes to these wonderful people (emoji key):fede💻🐛📖Greg DeVos🤔Cristian Challu💻mergenthaler📖💻Kin💻🐛🔣José Morales💻Alejandro💻stefanialvs🎨Ikko Ashimine🐛vglaucus🐛Pietro Monticone🐛This project follows theall-contributorsspecification. Contributions of any kind welcome!