Installing FBProphet/Prophet for Time Series Forecasting in Jupyter Notebook
By: Handhika Yanuar Pratama
Tags: Time Series Analysis, Forecasting, Anaconda, Machine Learning, Python

Photo by Wil Stewart on Unsplash

Time series forecasting is one of most demanding object in machine learning. The easiest way for projecting your time series data is using a module named Prophet (a.k.a. fbprophet). Prophet is a procedure for forecasting time series data based on an additive model where non-linear trends are fit with yearly, weekly, and daily seasonality, plus holiday effects.

Prophet module is released by Facebook’s Core Data Science team, you can read full documentation here. Although this module make the forecasting easier, but the installation in Jupyter Notebook is somehow really hard and has many problem. The problem happened more likely into beginner and whenever the beginner feel hard about installing it, they quit the machine learning.

After struggling about the installation for several hours, in this post I want to share about how I face the problem. I hope this post can help others who have the same problem with me.

Problem Declaration

How to install Prophet (fbprophet) in your local computer?

Solution

The problem actually exist for people who had installed Python > 3.9 from the original source. We don’t need to blame anyone, but Prophet will only work for Python < 3.9. Well, don’t worry if you had installed it, because Python has virtual environment named Anaconda.

Anaconda is a distribution of Python and R in scientific computation. In this post, I will not talk about it, because it beyond the topic. But, I believe that everyone who read this post has Anaconda in their device because we want to install prophet in the jupyter notebook environment.

I will credit the this discussion in stack overflow as the reference for my solution. So, after do some self-questioning, I decide to build new environment in Anaconda, this environment will only focus in time series computation. So whenever I need it, I will use it without any fear of error anymore.

Without much talk, let’s go into the solution

1. First install Anaconda or miniconda in your Windows machine. You can get the installation page here.

2. Don’t forget to add anaconda python path into environment variable inside Windows system Path.

3. After have anaconda installed in your device and adding it into windows system path. You must be can access anaconda using conda command in your command line

4. Here, I will build new virtual environment called time_series, this environment will run in Python 3.8, so the command that I use is this

conda create -n time_series python=3.8

5. After a few time, the installation for new environment will done, now you can access your environment using this command

conda activate time_series

You see, now your command line have the environment named ‘time_series’ before the directory location.

6. Install the C++ compiler, using this command

conda install libpython m2w64-toolchain -c msys2

The installation will take several minutes based on your internet connection. The libpython library will automatically create and setup distutils.cfg into our Pythonpath\Lib\distutils. Because, we are using new virtual environment, we don’t need to worry about the installation will failed.

7. Now let’s do installation of the dependencies that will be required by Prophet (a.k.a. fbprophet).

conda install numpy cython -c conda-forge

conda install matplotlib scipy pandas -c conda-forge

conda install pystan -c conda-forge

conda install -c anaconda ephem

8. Install the library that will used for your time series forecasting environment

scikit-learn

auto-arima (pmdarima)

fbprophet

I just realize that the fbprophet name had been change into Prophet from this discussion

So, don’t forget to install Prophet too, using the command above

pip install pystan==2.19.1.1 prophet

or

conda install -c conda-forge prophet

9. Test the prophet modules is it installed or not

Well the testing is done and there is no error.

Conclusion

In this post, I was explained about how to install fbprophet/prophet in your device. This post is tested and work in my device (Windows 10). The main problem of the installation, in my case because I already installed python 3.9 so, the prophet can’t be installed. I don’t want to reinstall the python from my device, so I use anaconda environment to build new environment for my time series job.

Bonus Actually you can install it quickly using google colab and use it online. But, I don't really recommend it because you need to work always with internet connection.

Lastly, thanks for read this article into this end. I hope it gonna be useful

Have a Nice Code ✌