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
PQKmeans can be pickled! #18
Conversation
|
||
# save current engine and recover from savedata | ||
engine_savedata = pickle.dumps(engine) | ||
engine_recovered = pickle.loads(engine_savedata) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just pickle the trained engine instead of creating new class
init_centers = [] | ||
self._impl = _pqkmeans.PQKMeans(encoder.codewords, k, iteration, verbose, init_centers) | ||
self.encoder = encoder | ||
self._impl = _pqkmeans.PQKMeans(self.encoder.codewords, k, iteration, verbose) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I removed init_centers
to unify the way of loading trained instance. @insikk
pqkmeans/clustering/pqkmeans.py
Outdated
return PQKMeansSavedata( | ||
encoder=self.encoder, | ||
k=self._impl.k_, | ||
iteration=self._impl.k_, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be self._impl.iteration_
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh sorry, i've fixed it.
Implemented
__getstate__
and__setstate__
on PQKmeans following the way #17 .So now we can pickle PQKmeans.