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.
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.start()
df = pd.read_csv("example_wp_log_peyton_manning.csv")
m = Prophet()
m.fit(df)
# Your training code
Note
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.
Note
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¶
python -m pip install "comet_ml>=3.44.0" 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
comet_ml.login()
experiment = comet_ml.start(project_name="comet-example-prophet-doc")
# You will need to download this file from
# https://raw.githubusercontent.com/facebook/prophet/main/examples/example_wp_log_peyton_manning.csv
df = pd.read_csv("./example_wp_log_peyton_manning.csv")
model = Prophet()
model.fit(df)
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.
- For more examples using Prophet, see our examples GitHub repository.
- Run the end-to-end example above in Colab:
Configure Comet for Prophet¶
Prophet code | What is automatically logged | How to control |
---|---|---|
Prophet() | logs all hyperparameters | Experiment(auto_param_logging=True) |
model.fit() | logs model | Experiment(log_graph=True) |
cross_validation() | logs items logged with model.fit() | Experiment(log_graph=True) |
plot() | logs matplotlib figure | COMET_AUTO_LOG_FIGURES=1 or in ~/.comet.config |
plot_components() | logs matplotlib figure | COMET_AUTO_LOG_FIGURES=1 or in ~/.comet.config |
plot_cross_validation_metric() | logs matplotlib figure | COMET_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
.