Skip to content

Instantly share code, notes, and snippets.

@caiofcm
Created October 12, 2020 23:40
Show Gist options
  • Save caiofcm/bf25b86a83b3bf736181fb91f1bd683c to your computer and use it in GitHub Desktop.
Save caiofcm/bf25b86a83b3bf736181fb91f1bd683c to your computer and use it in GitHub Desktop.
Running Facebook Phrophet in a Docker container

Running Facebook Phrophet in a Docker container

Setup

The Dockerfile in a working folder:

FROM python:3.7
# based on: https://gist.github.com/stefanproell/89a00f3a2c18a7e9549a1de6f82cf0f8

RUN apt-get -y update && apt-get install -y \
  python3-dev \
  libpng-dev \
  apt-utils \
  python-psycopg2 \
  python-dev \
  postgresql-client \
&& rm -rf /var/lib/apt/lists/*

RUN pip install --upgrade setuptools
RUN pip install cython
RUN pip install numpy
RUN pip install matplotlib
RUN pip install pandas
RUN pip install pystan
RUN pip install fbprophet
RUN pip install psycopg2
RUN pip install sqlalchemy

WORKDIR /forecast
#COPY . /forecast/
#CMD [ "python", "./run_forecast.py" ]

Recommended for testing:

Copy https://raw.githubusercontent.com/facebook/prophet/master/examples/example_wp_log_peyton_manning.csv to the working folder as example_wp_log_peyton_manning.csv.

Building Docker Image

From the working dir:

docker build -t phrophet-py37 .

I received un error but it succeeded anyway.

Running the docker container

The following command will run the docker image with a mounted volume to the working folder:

docker run -ti -v ${PWD}:/forecast phrophet-py37 /bin/bash

Testing with phrophet documentation:

ls #should show the files from the host file system
python #start python

In the python REPL:

# Python
import pandas as pd
from fbprophet import Prophet
df = pd.read_csv('example_wp_log_peyton_manning.csv')
df.head()

m = Prophet()
m.fit(df)

future = m.make_future_dataframe(periods=365)
future.tail()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment