Skip to main content

Prophet Logging

Import necessary packagesโ€‹

from katonic.ml import MyClient
import numpy as np
from prophet import Prophet
from sklearn.metrics import mean_absolute_error, mean_squared_error, r2_score
from sklearn.model_selection import train_test_split
import pandas as pd

Create client object using MyClientโ€‹

myclient = MyClient()
mlflow = myclient.mlflow
client = myclient.client

Implement model training and logging stepsโ€‹

exp_name = "mlflow-test-prophet"
mlflow.set_experiment(exp_name)
exp_details = mlflow.get_experiment_by_name(exp_name)
with mlflow.start_run(run_name=exp_name):
data = pd.read_csv('https://raw.githubusercontent.com/facebook/prophet/main/examples/example_wp_log_peyton_manning.csv')

model = Prophet()
model.fit(data)

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

model_info = mlflow.prophet.log_model(pr_model=model, artifact_path="model")