export a .model file from dataiku jupyter notebook

Solved!
tucel
Level 2
export a .model file from dataiku jupyter notebook

Hello dataiku community,

I trained a model in dataiku jupyter notebook and want to export it in .model format.

Here is my export code:

best_model.save_model('best_model.model')

When I run this code it works, but I could not find where 'best_model.model' file. Do you have any ideas where this file goes?

 

Thank you!

 

0 Kudos
1 Solution
RoyE
Dataiker

Hi,

Looking through XGBoost documentation, you can either input a string or os.Pathlike as the parameter into save_model.

I would suggest using the full path to save your file to mitigate any confusion. 

save_model("/<DSS_DATA_DIR>/config/projects/<project_name>/modelname.model")

Let me know if this works and if there are any further questions.

Roy

 

View solution in original post

0 Kudos
4 Replies
RoyE
Dataiker

Hello Tucel,

Could you provide a bit more context on which package your save_model function is derived from?

From what I checked (utils and keras), the save_model function requires at least a model argument and a file path. According to the code snippet that you provided, only the model was provided. Possibly your function defaults to a directory but without knowing the provider, it is difficult to say.

Furthermore I did a quick test with the built-in function "open" and noticed that if you simply write a file name, the file does not create. However, if you input a full path, the file does create.

IE:

f = open("test.txt", "w")
f = open("/path/to/dir/test.txt". "w")

 

Please let me know so that I can run some tests on my side and get back to you! 

Roy

tucel
Level 2
Author

Thanks for quick return. save_model function is coming from xgboost. And can you explain how should I write the correct path. For example path like below does not work: 

f = open("/projects/project_name/test.txt", "w")

 

0 Kudos
RoyE
Dataiker

Hi,

Looking through XGBoost documentation, you can either input a string or os.Pathlike as the parameter into save_model.

I would suggest using the full path to save your file to mitigate any confusion. 

save_model("/<DSS_DATA_DIR>/config/projects/<project_name>/modelname.model")

Let me know if this works and if there are any further questions.

Roy

 

0 Kudos
tucel
Level 2
Author

Thanks Roy!

It solved my problem. Additional info for other community members: I created a folder in my flow and redirect my saved models into it, so I can access my all saved files easily.