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

Clusters in HitMapView #24

Closed
anjomshoaa opened this issue Jun 30, 2016 · 15 comments
Closed

Clusters in HitMapView #24

anjomshoaa opened this issue Jun 30, 2016 · 15 comments

Comments

@anjomshoaa
Copy link

Hi,

I have a question about the HitMapView. I do clustering as follows and the output is perfectly fine:

cl = som.cluster(n_clusters=3)

But the HitMapView always uses the default number of clusters which is 8 and I could not find a way to change it:

h = hitmap.HitMapView(10, 10, 'hitmap', text_size=8, show_text=True)

How can I specify number of clusters in a HitMapView to a different number?

Regards
Amin

@sevamoo
Copy link
Owner

sevamoo commented Jul 4, 2016

Hi @anjomshoaa there was an issue in som.cluster() that it didn't set the cluster labels. Now should be fine.
Could you please check it out?

@sevamoo sevamoo closed this as completed Jul 5, 2016
@anjomshoaa
Copy link
Author

Thanks Vahid jan,

Yes, it is working perfectly now.

Best regards
Amin

@gsvijayraajaa
Copy link

Is there a way to get the index of the training data for the individual cluster labels?

@sevamoo
Copy link
Owner

sevamoo commented Aug 29, 2017

by clustering you get the labels of nodes. By project function you get the bmus. So, then use something like this
cl = som.cluster(n_clusters=3)
bmus = som.project()
cl_data = cl[bmus]

@gsvijayraajaa
Copy link

gsvijayraajaa commented Aug 29, 2017 via email

@sevamoo
Copy link
Owner

sevamoo commented Aug 29, 2017

Yes, there is one.

def project_data(self, data):

@gsvijayraajaa
Copy link

gsvijayraajaa commented Aug 30, 2017

Using the project_data function , I need to project back the training data to the trained model? Also, from the bmus, how do I tie it back to the original training data index? Essentially I would like to find the list of training data index corresponding to the cluster label.

@vishvanath45
Copy link

@gsvijayraajaa Did you get a way get the output category label back to data.

@vedavikas06
Copy link

vedavikas06 commented Jun 16, 2018

to cluster the neurons into 4 clusters

cl = som.cluster(n_clusters=4)

this will map the data X to the respective neurons in som

bmus = som.project_data(X)
print(bmus)

this gives the corresponding cluster number for the data in X

cl_data = cl[bmus]
print(cl_data)

@vishvanath45
Copy link

Thanks it worked!

@businessglitch
Copy link
Contributor

Hey @sevamoo, really need help with this issue. I have a dataset of length 50,000 when i do cl = som.cluster(n_clusters=2)

cl returns lables which is fine but the length of 1120. Which is understandable because the data points are under a cluster.

but when I do cl_data = cl[bmus], this creates duplicate indexs like there would be 7 1's 5 2's and so on, which is not correct because the model wouldn't use duplicated values. Any advice on this would be appreciated. I believe it has something to do with the length of cl the 1120

@nehamalik1978
Copy link

nehamalik1978 commented Jan 2, 2019

I have used the below code: to find label and index of cluster:
cl = som.cluster(n_clusters=3)
bmus = som.project()
cl_data = cl[bmus]

How do I find which cluster my data belongs to?
I tried:

N_CLUSTERS = 3
clusters = [input_data[km == i] for i in range(N_CLUSTERS)]
for i, c in enumerate(clusters)
print('Cluster {} has {} members: {}...'.format(i, len(c), c[0]))

but it is showing error: item length not match

@sevamoo
Copy link
Owner

sevamoo commented Jan 3, 2019

I believe this is the answer you are looking for: cl_data = cl[bmus]

@kedarnaik33
Copy link

Hi Sevamoo,

I have a question, in the som.cluster(n_clusters = 8), I have set 8 clusters and it gives me clusters from 0 to 7.

However, my test set labels are from 1 to 8 and when I use accuracy_score it obviously gives me a wrong accuracy.

I wanted to know if there is a way to set the cluster number from 1 to 8 ?

Would really appreciate your help.

Sincerely,
Kedar

@akol67
Copy link

akol67 commented Jul 15, 2021

Using the project_data function , I need to project back the training data to the trained model? Also, from the bmus, how do I tie it back to the original training data index? Essentially I would like to find the list of training data index corresponding to the cluster label.

Did you have some help to accomplish that list of training index?

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

9 participants