How to utilize packages built in forecasting plugin

swapnilk
Level 1
How to utilize packages built in forecasting plugin

After using the forecast plugin, the models get stored in a folder with the name of model.pk.gz, unzipping it to model.pk but this binary file is inaccessible. 

0 Kudos
3 Replies
AlexT
Dataiker

Hi, Welcome to the Dataiku Community! The model.pk file is a pickle binary file.You can use it using python. Could please elaborate what exactly you are trying to do? 

import pickle              # import module first
from gluonts.dataset.common import ListDataset

f = open('gluon_train_dataset.pk', 'rb')   # read
mylist = pickle.load(f)         # load file 
f.close() 

# This will be gluonts.dataset https://ts.gluon.ai/api/gluonts/gluonts.dataset.common.html 

 

0 Kudos
swapnilk
Level 1
Author

Hi Alex,

Thanks for the reply. I'm trying to access the codes written in model.pk file generated by forecast plugin.

0 Kudos
AlexT
Dataiker

Hi,

The model.pk file in our case would be in my example is  gluonts.model.trivial.identity.IdentityPredictor object. The code of the actual plugin is available here. 

import pickle              
from gluonts.dataset import common

f = open('model.pk', 'rb')   # 'r' for reading; can be omitted
pickle_data = pickle.load(f)         # load file content as mydict

print(pickle_data.__dict__ ) 

#example output {'__init_args__': OrderedDict([('freq', 'D'), ('num_samples', 100), ('prediction_length', 1)]), 'prediction_length': 1, 'freq': 'D', 'lead_time': 0, 'num_samples': 100}

 Let me know if there is anything further I help with. 

0 Kudos