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

Save DBScan Model #650

Closed
EricCacciavillani opened this issue Nov 8, 2020 · 3 comments
Closed

Save DBScan Model #650

EricCacciavillani opened this issue Nov 8, 2020 · 3 comments
Assignees
Labels
Bug Tasks related to found bugs

Comments

@EricCacciavillani
Copy link

First off thank you so much for writing this package! Been having a blast with it and the documentation is amazing!

I found a bug though when I try to pickle.load the object back from a pickle file and it results in this error.

image

@annoviko
Copy link
Owner

annoviko commented Nov 8, 2020

Hello @EricCacciavillani ,

Thank you for your reporting. Yes, I can recognize it. It because pyclustering uses C++ code to get maximum performance (I rewrite some of the algorithms using C++) and not all internal data is transferred back to python, only results. And as a result object cannot be restored. I think this is an issue for almost all algorithms which delegate calculation to C++ implementation.

I will investigate the issue and will introduce correction for all clustering algorithms.

Still, it would be useful to have a code example, I would like to know the use-case if it is possible.

@annoviko annoviko added the Bug Tasks related to found bugs label Nov 8, 2020
@EricCacciavillani
Copy link
Author

EricCacciavillani commented Nov 8, 2020

Sorry for responding so late was helping a co-worker.

from pyclustering.cluster.dbscan import dbscan
import pickle

# Data that has had pca and scaled
scaled = auto_cluster.get_scaled_data()

# Model instance
dbscan_instance = dbscan(scaled, .07865, 8, True)
dbscan_instance.process()

# Save model to dir
file_dir = 'DBScan.pkl'
list_pickle = open(file_dir, 'wb')
pickle.dump(dbscan_instance,list_pickle)
list_pickle.close()

# Load model in
with open(file_dir, 'rb') as handle:
    load_model = pickle.load(handle)

@annoviko annoviko self-assigned this Nov 9, 2020
@annoviko
Copy link
Owner

annoviko commented Nov 9, 2020

I have supported dumping and loading of the algorithm. The changes are on the branch 0.10.dev, and they will be available in the next release 0.10.1.

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

No branches or pull requests

2 participants