I already have k means output and i have segmented my users accordingly. Now, I have to predict cluster number for new users whenever they come. Do I have to run kmeans each time a new user comes into the picture or is there any easy way like using predict function. Please let me know if there is any ready example for this. Thanks, Sagar
Asked
Active
Viewed 694 times
-1
-
Possible duplicate of [How to know which cluster do the new data belongs to after finishing cluster analysis](http://stackoverflow.com/questions/17567801/how-to-know-which-cluster-do-the-new-data-belongs-to-after-finishing-cluster-ana) – Has QUIT--Anony-Mousse Mar 30 '16 at 16:43
-
Also, please **do not cross-post**: http://stats.stackexchange.com/q/204512/7828 and use the search function to find related questions first. We already have many duplicates of this question... – Has QUIT--Anony-Mousse Mar 30 '16 at 16:49
1 Answers
0
Each cluster has a corresponding centroid. When a new datapoint arrives, you can just assign to the cluster corresponding to the centroid that is closest to the new point.
Alternatively, you can instead do another step of the k
-means algorithm, but you don't have to run it from scratch.
Perhaps more importantly, is there a bound on the number of users that can enter? If the number (of new users that may enter) is large enough to change the clusters (so that what you have computed is no longer valid), then you might want to consider data stream clustering.

blazs
- 4,705
- 24
- 38
-
Thanks blaz. How to run only a step of kmeans? sorry this might be easy one but i am new in R. – Sagar Mar 30 '16 at 10:31
-
-
@Sagar, can you specify the R package that you're using? :-) So that I can read the documentation to see how to get centroids, do a single k-means step, etc. – blazs Mar 30 '16 at 10:37
-
-
Yes, but what _package_? Maybe you just copy and paste the relevant code? – blazs Mar 30 '16 at 10:39
-
@ Blaz, can you please help me with how to find my package name for kmeans – Sagar Mar 30 '16 at 10:47
-
@Sagar, yes, but I can only do that if I see the code. You probably imported the package using `library(packageName)` in R. Can you list all `packageName`'s ? – blazs Mar 30 '16 at 10:51
-