How to save model in pickle such that when loaded it takes user input and predict future
- 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
Assessment
This issue has not been assessed yet.