export a .model file from dataiku jupyter notebook

Options
tucel
tucel Partner, Registered Posts: 9 Partner

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!

Best Answer

  • RoyE
    RoyE Dataiker, Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Dataiku DSS Adv Designer, Registered Posts: 31 Dataiker
    Answer ✓
    Options

    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

Answers

  • RoyE
    RoyE Dataiker, Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Dataiku DSS Adv Designer, Registered Posts: 31 Dataiker
    Options

    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
    tucel Partner, Registered Posts: 9 Partner
    Options

    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")

  • tucel
    tucel Partner, Registered Posts: 9 Partner
    Options

    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.

Setup Info
    Tags
      Help me…