I am using the prophet forecaster from python’s sktime package
https://www.sktime.net/en/stable/api_reference/auto_generated/sktime.forecasting.fbprophet.Prophet.html
I am not sure how to add custom seasonalities correctly and how to consider them in the fit. I tried the following:
import pandas as pd
from sktime.forecasting.fbprophet import Prophet
# Example data creation
dates = pd.date_range(start='2023-01-01', end='2023-01-31')
data = {'dt': dates, 'y': range(len(dates))}
df_train = pd.DataFrame(data)
# Create a custom 'weekday_flag' column
df_train['weekday_flag'] = df_train['dt'].dt.weekday < 5 # Monday=0, ..., Friday=4
# Define custom seasonality with condition 'is_weekday'
custom_seasonality = [
{
"name": "weekday_seasonality",
"period": 1,
"fourier_order": 3,
"condition_name": "weekday_flag",
}
]
# Initialize Prophet model with custom seasonality
prophet_model = Prophet(add_seasonality=custom_seasonality)
# Fit the Prophet model using the features and target
X = df_train[['weekday_flag']].set_index(df_train['dt'])
y = df_train[['y']].set_index(df_train['dt'])
prophet_model.fit(X=X, y=y)
But I am getting the error TypeError: ufunc 'invert' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
.
Any hints how to resolve it? Do I need to change the format of X and y?