ObjAITimeProphet Module DocumentationThis document provides documentation for the ObjAITimeProphet module. This module provides a specific implementation of the ObjAITime base class, using the Prophet library for time-series forecasting.
ObjAIQuery ClassThis class inherits from ObjAITime.ObjAIQuery and is tailored to use the Prophet forecasting model.
This class inherits all public methods and class members from ObjAITime.ObjAIQuery, including read, get_date_range, insert_prediction_rows, and get_training_dataframe.
initialize_prophet_model(self, df: pd.DataFrame) -> ProphetTakes a Pandas DataFrame of training data, initializes a Prophet model instance, and fits the model to the data. It returns the fitted Prophet model object.
generate_plots(self, model_prophet: Prophet, forecast_df: pd.DataFrame) -> NoneReceives a fitted Prophet model and a forecast DataFrame. It generates two plots:
These plots are saved as PNG images in the directory specified by the _Localaidocuments class member.
update_predictions(self, forecast_df: pd.DataFrame) -> NoneTakes a forecast DataFrame and iterates through its rows. For each row, it updates the y_predict column in the prediction table in the database with the forecasted value (yhat).
query(self)This is the main orchestration method, which overrides the base class method to implement the full Prophet forecasting workflow:
read() to load the configuration.get_date_range() to determine the time period.insert_prediction_rows() to prepare for future predictions.get_training_dataframe() to prepare the data for the model.initialize_prophet_model() to create and fit the Prophet model.update_predictions() to save the forecast to the database.generate_plots() to visualize the forecast.