Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How save model in file? #5

Closed
axsapronov opened this issue Aug 16, 2015 · 13 comments
Closed

How save model in file? #5

axsapronov opened this issue Aug 16, 2015 · 13 comments

Comments

@axsapronov
Copy link
Contributor

Hi all,
I took example (from docs), and i want to save classifier to file.
But if:

with open('dump_autosk.pkl', 'wb') as fio:
    pickle.dump(automl, fio)

I got

TypeError: Pickling an AuthenticationString object is disallowed for security reasons

Can i save model in file?

@mfeurer
Copy link
Contributor

mfeurer commented Aug 31, 2015

Hi,
at the moment it is not possible to save the found models to a file. I will leave this issue open to remind us of adding this feature.

@mglowacki100
Copy link

Hi,
Here is nice approach to saving model:
http://rhiever.github.io/tpot/examples/IRIS_Example/

@mfeurer
Copy link
Contributor

mfeurer commented Mar 30, 2016

This is not the same as the thread creator asked for. You can achieve something similar by using AutoSklearnClassifier.show_models(), which prints you the members of the final ensemble, together with their weight. So far, this is only possible because of the rather simple ensemble considered and will possibly vanish in the near future.

@mfeurer
Copy link
Contributor

mfeurer commented May 24, 2016

auto-sklearn supports pickle with commit 9415f38

@mfeurer mfeurer closed this as completed May 24, 2016
@devonbrackbill
Copy link

I'm not able to get pickle to work with commit 9415f38. When I install the development branch + the refactor/cleanupcomponents branch and run the test/test_automl/test_pickle.py file I still get the following error: TypeError: Pickling an AuthenticationString object is disallowed for security reasons. Any ideas what I'm doing wrong? Or how I could help make pickle work here?

@mfeurer
Copy link
Contributor

mfeurer commented Sep 13, 2016

Sorry for the late reply. I think there was an error on my side. Can you please try the latest version of the development branch? That should work. Is there any reason why you want to use refactor/cleanupcomonents?

@mfeurer
Copy link
Contributor

mfeurer commented Sep 13, 2016

Sorry, my bad. Of course you wanted to use the branch because the commit was in there. Please only use the development branch now.

@devonbrackbill
Copy link

Thank you! It works on the development branch. My mistake for using the incorrect branch.

@RedLiN5
Copy link

RedLiN5 commented Nov 10, 2016

Hi guys. I've tried 9415f38 to save model.
But I got this error:

File "automl_classification.py", line 73, in main
    pickle.dump(automl, f)
_pickle.PicklingError: Can't pickle <class 'smac.runhistory.runhistory.RunKey'>: attribute lookup RunKey on smac.runhistory.runhistory failed

Does anyone know why it doesn't work?

@mfeurer
Copy link
Contributor

mfeurer commented Nov 10, 2016

See issue #138. A fix is under construction.

@namankumar
Copy link

namankumar commented Nov 27, 2016

A clean hack for saving the best model:

x = automl.show_models()
results = {"ensemble": x}
pickle.dump(results, open('fname.pickle','wb'))

@gstempeck
Copy link

When you save the models using show_models() like namankumar lists, how do you re-load and execute the predict() from the pickle file?

When I pickle.dump(classifierobj) I get a MemoryError but I assume that's the correct way to reload classifierobj to call predict().

@mfeurer
Copy link
Contributor

mfeurer commented Aug 26, 2017

Yes, that's the correct way to do this. I cannot explain when/why this happens as it never occured to me. Could you please provide some information about the data you're using (number of features and number of data points, sparse or not) and your system (especially RAM and bit)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants