facebook / facebook/prophet

How to save model in pickle such that when loaded it takes user input and predict future

Open
#2,158 1 comment 0 reactions 0 assignees View on GitHub
question
Dominant language
Python
Stars
20.4k
Forks
4.6k
Avg merge
19h 52m
Merged PRs (30d)
1

Description

Hi,

I have built an prophet model which contains date and items as columns. There are 50 such item columns. I need to save this model in pickle format. Since prophet takes 'ds' and 'y' column, each time I load the model, it should take 'item_number' as user input i.e. 'y', then predict the future dates. How to save the model such that it takes user input when loaded. Below is the code of model fitting.

```
def model_fit(item_number):
#Calling the dataframe for specific item
item_data = data(item_number) #Function call - data(item_number)
train, test = item_data[item_data['ds'] <= '2016-12-31'], item_data[item_data['ds'] > '2016-12-31']
model = Prophet(interval_width = 0.80, changepoint_range = 0.9)
model.fit(train)

return model
```

In the above code, when I run, `model = model_fit(item_number)`, it fits the model of training data for that particular item. If I save this into pickle, it saves the model fitted for that item_number alone. How to save the model such that when the model is loaded, the 'item_number' is taken as input.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.