-
Notifications
You must be signed in to change notification settings - Fork 19
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
Example needed for persisting Birch model using _ClusteringWrapper or similar #184
Comments
Thanks for the feedback @robguinness! If you want to use this version of Birch in Python, just use, from freediscovery.cluster import Birch instead of from sklearn.cluster import Birch everything else should be mostly the same as with the Birch estimator from scikit-learn: see documentation at http://freediscovery.io/doc/stable/user_manual/clustering.html#birch for more details. There is a more complete example in http://freediscovery.io/doc/stable/python/examples/birch_cluster_hierarchy.html The serialization should work the same as with regular scikit-learn estimators, from sklearn.externals import joblib
joblib.dump(estmator, 'file_name.pkl') As to |
Thanks for the reply @rth. I want to clarify my issue a bit. Persisting with joblib or pickle is one possibility, but what I would really like to do is utilize freediscovery's consistent approach of persisting models and the associated metadata, as found in @marshal_with(IDSchema())
def post(self, **args):
from math import sqrt
metric = args.pop('metric')
S_cos = _scale_cosine_similarity(args.pop('min_similarity'),
metric=metric,
inverse=True)
# cosine sim to euclidean distance
threshold = sqrt(2 * (1 - S_cos))
cl = _ClusteringWrapper(cache_dir=self._cache_dir,
parent_id=args.pop('parent_id'),
metric=metric)
if args.get('n_clusters') <= 0:
args['n_clusters'] = None
cl.birch(threshold=threshold, **args)
return {'id': cl.mid} However, I later found out that this version of the Birch model created by I really like the idea of interacting with freediscovery through REST APIs, but not 100% of the features I need are currently available through the REST APIs, and I am interested to eventually extend them. Still getting my feet wet though... |
Thanks for the additional explanations! You are of course free to use the To answer your initial question, If you encounter any issues, e.g. while using scikit-learn 0.20rc1 don't hesitate to open issues. Pull Requests would also be very appreciated! |
Thanks. This is very helpful! I will certainly send a PR if I come up with anything useful ;-) |
Hi again,
Any ideas? |
Hi,
I am new to FreeDiscovery. I came across it when reading this pull request. The features you added to Birch are really great, but I am stuck figuring out how to persist a Birch model according to your API.
I have tried persisting using the
_ClusteringWrapper
class, as in this example:The problem is when I try to interact with it using the Birch API, I get an error, e.g.:
OUT:
ValueError: the birch object must be created with freediscovery.cluster.Birch
An example of how to persist a Birch model and work with it later using the Birch API would be most appreciated!
The text was updated successfully, but these errors were encountered: