Skip to content

Integrate with Prophet

Facebook Prophet is a fast forecasting procedure for time series (calendar) data that provides complete automated forecasts that can be further tuned by hand.

Open In Colab

Start logging

Connect Comet to your existing code by adding in a simple Comet Experiment.

Add the following lines of code to your script or notebook:

import comet_ml

import pandas as pd
from prophet import Prophet

experiment = comet_ml.Experiment(
    api_key="<Your API Key>",
    project_name="<Your Project Name>"

df = pd.read_csv("example_wp_log_peyton_manning.csv")

m = Prophet()
# Your training code


There are other ways to configure Comet. See more here.

Log automatically

After an Experiment has been created, Comet automatically logs the following Prophet items, by default, with no additional configuration

  • Hyperparameters
  • Model
  • Figures

You can easily turn the automatic logging on and off for any or all items. See Configure Comet for Prophet for more details.


Don't see what you need to log here? We have your back. You can manually log any kind of data to Comet using the Experiment object. For example, use experiment.log_image to log images, or experiment.log_audio to log audio.

End-to-end example

Following is a basic example of using Comet with Prophet.

If you can't wait, check out the results of this example Prophet experiment for a preview of what's to come.

Install dependencies

pip install comet_ml prophet plotly

Run the example

import comet_ml

import os
import pandas as pd
from prophet import Prophet
from prophet.diagnostics import cross_validation
from prophet.plot import plot_cross_validation_metric

experiment = comet_ml.Experiment()

# You will need to download this file from
df = pd.read_csv("./example_wp_log_peyton_manning.csv")

model = Prophet()

future = model.make_future_dataframe(periods=365)
forecast = model.predict(future)

df_cv = cross_validation(
    model, initial="730 days", period="180 days", horizon="365 days"
plot_cross_validation_metric(df_cv, "mse")

Try it out!

Don't just take our word for it, try it out for yourself.

Configure Comet for Prophet

Prophet codeWhat is automatically loggedHow to control
Prophet()logs all hyperparametersExperiment(auto_param_logging=True) modelExperiment(log_graph=True)
cross_validation()logs items logged with
plot()logs matplotlib figureCOMET_AUTO_LOG_FIGURES=1 or in ~/.comet.config
plot_components()logs matplotlib figureCOMET_AUTO_LOG_FIGURES=1 or in ~/.comet.config
plot_cross_validation_metric()logs matplotlib figureCOMET_AUTO_LOG_FIGURES=1 or in ~/.comet.config

You can control each of these by setting the Experiment argument to False or the config variable to 0.

Jun. 5, 2024