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

Add clustering #68

Merged
merged 3 commits into from
Nov 9, 2023
Merged

Add clustering #68

merged 3 commits into from
Nov 9, 2023

Conversation

nicolomonti
Copy link
Collaborator

I've added some clustering experiments, be aware that to run the traditional clustering you need to install the kmeans from https://github.com/kernelmachine/cbtm



def train_kmeans(features, n_clusters, path_to_kmeans, balanced=False, device='cpu'):
kmeans = BalancedKMeans(n_clusters=n_clusters, device=device, balanced=balanced)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

want to note that on my local, n_clusters is not a parameter, but num_clusters is -- does this work for you?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad - I did some refactoring on Huu's codebase and changed its name, will update it ASAP

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

additionally, since I'm not using KMeans, but kmeans -- cannot be instantiated without X, which needs to be a torch object or else it fails
if this worked for you, great -- will sync up with you to figure out why it didn't on my env
if not, then we'll need to figure out a way to use pytorch-kmeans in batches since instantiation isn't immediately possible -- open to suggestions here


from torch.utils.data import DataLoader, IterableDataset

from kmeans_pytorch import KMeans as BalancedKMeans
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

had issues with importing KMeans, turned up an error
but no issues importing kmeans -- did you experience this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you use the kmeans from pip or the one from https://github.com/kernelmachine/cbtm?

@huu4ontocord huu4ontocord merged commit 668f1bd into huu4ontocord:main Nov 9, 2023
1 check failed
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

Successfully merging this pull request may close these issues.

3 participants