简体   繁体   中英

How to manually register a sci-kit model with TRAINS python auto-magical experiment manager?

I'm working mostly with scikit-learn, as far as I understand, the TRAINS auto-magic doesn't catch scikit-learn model store/load automatically.

How do I manually register the model after I have 'pickled' it.

For Example:

import pickle
with open("model.pkl", "wb") as file:  
    pickle.dump(my_model, file)

Assuming you are referring to TRAINS experiment manager: https://github.com/allegroai/trains (which I'm one of the maintainers)

from trains import Task, OutputModel
OutputModel(Task.current_task()).update_weights(weights_filename="model.pkl")

Or, if you have information you want to store together with the pickled model file, you can do:

from trains import Task, OutputModel
model_parameters = {'threshold': 0.123}
OutputModel(Task.current_task(), config_dict=model_parameters).update_weights(weights_filename="model.pkl")

Now, you should see in the UI an output model registered with the experiment. The model contains a link to the pickel file, together with the configuration dictionary.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM