Search code examples
pandaspysparkuser-defined-functionsfacebook-prophet

Pandas UDF Facebook Prophet / multiple parameters


I'm trying to scale multiple models with Facebook Prophet and Pandas UDF on spark. Everything works fine but I'd like to refine the models by giving different parameters to the function.

The function is grouped on the ID column of my dataset which is a combination of country and product. I would like the function to apply country specific holiday to the model, added to a general seasonality dataframe which I use to for example to remove COVID19 impact on the data. Eventually I would like to change any other parameter (e.g. different type of growth) depending on the ID value.

Thank you for your kind help.


Solution

  • The way I think I solved it is by adding another column in the training dataset and then point to the first value of that column for each respective model ID.

    So for example if the data has daily data points for the different IDs if the IDs is related to the US country, the new column points to this value for country level seasonality.

    day, id, value, country 4/1, US-Item1, 10, US 4/1, IT-Item1, 5, IT 4/1, US-Item2, 15, US