Working with Prophet#
Prophet is a popular time-series forecasting library.
With the Neptune–Prophet integration, you can keep track of parameters, forecast data frames, residual diagnostic charts, cross-validation folds, and other metadata while training models with Prophet.
See in Neptune  Code examples 
Related
- API reference ≫ Prophet
- neptune-prophet repository on GitHub
- Prophet documentation
- Prophet on GitHub
Before you start#
- Set up Neptune. Instructions:
- (optional) To log the plots as interactive HTML visualizations, you need to have the Plotly graphing library installed.
- You can enable logging as interactive HTML by setting the
log_interactive
parameter toTrue
where applicable. - Otherwise, the plots are recorded as static images by default.
- You can enable logging as interactive HTML by setting the
Installing the Neptune-Prophet integration#
Logging options#
In order to track the metadata to Neptune, you need to initialize a Neptune run.
Haven't registered?
If you haven't registered or set up your credentials, you can log anonymously to the public project:
You can then use the run
object to track metadata with the functions listed below.
Logging Prophet summary#
create_summary()
You can log all relevant metadata at once with this function, such as forecast plots and residual diagnostics.
Parameters
Parameter | Description |
---|---|
model |
Fitted Prophet model object. |
df (optional) |
The dataset that was used for making the forecast. If provided, additional plots will be recorded. |
fcst (optional) |
Forecast returned by Prophet. If not provided, it'll be calculated using the df data. |
log_charts |
Additionally save the diagnostic plots. Defaults to True . |
log_interactive |
Save the plots as interactive HTML files. Requires the Plotly library. Defaults to False . |
Returns
Dictionary with all the plots.
Example
import pandas as pd
from prophet import Prophet
import neptune
import neptune.integrations.prophet as npt_utils
run = neptune.init_run()
dataset = pd.read_csv(
"https://raw.githubusercontent.com/facebook/prophet/main/examples/example_wp_log_peyton_manning.csv"
)
model = Prophet()
model.fit(dataset)
run["prophet_summary"] = npt_utils.create_summary(
model=model, df=dataset, log_interactive=True
)
Getting the model configuration#
To extract the configuration from the Prophet model object, use the get_model_config()
function:
run = neptune.init_run()
dataset = ...
model = Prophet()
model.fit(dataset)
run["model_config"] = npt_utils.get_model_config(model)
Getting the serialized model#
To serialize the Prophet model, you can use the get_serialized_model()
function:
run = neptune.init_run()
dataset = ...
model = Prophet()
model.fit(dataset)
run["model"] = npt_utils.get_serialized_model(model)
Getting forecast components#
To get the forecast components (such as trend and monthly seasonality) produced by Prophet, use the get_forecast_components()
function:
run = neptune.init_run()
dataset = ...
model = Prophet()
model.fit(dataset)
predicted = model.predict(dataset)
run["forecast_components"] = npt_utils.get_forecast_components(model, predicted)
Logging forecast plots#
To save Prophet plots (such as forecast components, changepoints, forecast with prediction interval), use the create_forecast_plots()
function:
model.fit(dataset)
predicted = model.predict(dataset)
run["forecast_plots"] = npt_utils.create_forecast_plots(model, predicted)
Logging residual forecast plots#
To save additional diagnostic plots (such as histogram of residuals, ACF plot, QQ-plot for residuals) to Neptune, use the create_residual_diagnostics_plots()
function:
model.fit(dataset)
predicted = model.predict(dataset)
run["residual_diagnostics_plot"] = npt_utils.create_residual_diagnostics_plots(
predicted, dataset.y
)
See also
For details, see API reference ≫ Prophet