-
Notifications
You must be signed in to change notification settings - Fork 24.9k
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 K-means clustering feature #5512
Comments
It would be great! I really need this feature. Is there any estimate of when you will start coding? |
Not that I'm seeking to drop her in it, but Britta https://twitter.com/a2tirb would definitely have the madskillz to build this feature but not sure of her priorities/bandwidth/interest to attack this feature with sticks. I'm also not sure how new features are selected or voted up for prioritisation by elasticsearch overlords either. |
If I recall correctly, @geekpete proposed to have that in the context of aggregations, that is, build cluster and then use these as buckets inside the aggregations framework. Indeed, this would be an extremely useful feature. While it would be very much fun to implement unfortunately I do not think we will implement it in the near future. Anyone coming up with a pull request for this is of course more than welcome :-) For now I can only point you to the carrot2 plugin which does an excellent job in clustering search results. |
I'll add the comment that 'k' clusters ought to user-suppliable as an argument to the aggregation for maximum value, with possible k-values being:
For context, I brought this up @ the ElasticSearch Training in response to a brief conversation about search vs 'insight' in relation to data, the former where you know what you're looking for, the latter where you dont, or might not. The specific example was geospatial result sets with arbitrary demography data fields. It was a great session @brwe! |
I also would like to cast my vote for some kind of automated clustering feature. Carrot2 is great but as far as understand can only work on small amount of data. Would be great to have something that clusters ALL the data all the time. Maybe custom clustering analyzer? |
@clintongormley not really. Bucket reducers from #8110 would run on the final aggregation but clustering needs the documents. |
@brwe I think implementing clustering as a reducer could help reduce the cost very significantly? K-means is costly so running such an algorithm on a dataset containing lots of documents could be very slow. On the other hand, if we take geo-clustering as an example, we could make it very fast (though a bit lossy) by working on top of the output of the geo-hash grid aggregation as a bucket reducer? |
True, I should distinguish use cases. For up to 2d it might help indeed. For text clustering I do not see it. |
just found this - would be great. +1 |
+1 |
search for this... this would be a very great feature. Also other Mining-algorithms. |
Implementing this as a pipeline aggregation should now be possible. In that case we would first collect values into buckets using other aggregations and then use the pipeline aggregation to create clusters from those buckets. |
that would be mad! |
@koobs is there a recording of this session somewhere out there? |
@lessless I hope not :) |
This would really be awesome! |
+1 |
6 similar comments
👍 |
+1 |
+1 |
+1 |
+1 |
+1 |
Could we collate potential future features on a special section of the roadmap perhaps? |
Stalled waiting on #26659 /cc @elastic/es-search-aggs |
Still desired :) |
Indeed !! very desired ! |
@colings86 should "stalled" label be removed now? #26659 was closed in favor of #28993 which is merged now |
It is true that because #28993 is merged the "stalled" label can be removed. |
I also confirm it's very desired and I'd be happy to see it. |
+1 for this |
+1 |
Is the size parameter in https://www.elastic.co/guide/en/elasticsearch/reference/7.0/search-aggregations-bucket-geotilegrid-aggregation.html something like k-means-clustering for geo-search? |
@barracuda317 Not really, no. GeoTile just overlays a fixed grid over the area and aggregates documents into those grid cells. The grids are constructed irregardless of the data distribution (think of it more like a heatmap). Clustering like k-means dynamically identifies regions of data that are "similar" and groups them together into a cluster. Clustering can give you individual clusters that are different shapes, sizes, and densities. For a practical example, a clustering algo might group all the values inside a city together, then cluster the rural countryside together as a different group (much larger but also more sparse) |
@colings86 is there a reason why this was never completed? If the issue is time commitment, I'm very interested in this feature and would like to try finishing the implementation. |
@jamesdorfman Can you please describe your use case. Are you interested to have k-means clustering on geo data (they can be up to 8 dims)? |
@mayya-sharipova +1 to exactly that use case |
@mayya-sharipova yes, I was specifically interested in implementing the geo data use case. This thread made it seem as though this specific feature is highly desired. Furthermore, I'm not completely certain about how difficult this will be to implement, so I also think that the restricted use case of clustering only geo data is a good starting point. |
Another use case was to group ranges of prices of products within an index, and use k-cluster to propose cluster of prices to use with price selection. |
Upon further research and experimentation it seems that a more straightforward approach would be to implement an agglomerative hierarchical clustering algorithm, rather than k-means clustering. K-means involves creating k buckets, and then reassigning data points at each iteration of the algorithm. On the other hand, in agglomerative hierarchical clustering each point is initially placed in its own cluster. Then, these clusters are merged together on subsequent iterations. I am currently working on implementing this clustering feature as a histogram multi-bucket aggregation. The k-means approach would involve moving documents between buckets at each iteration; however, the hierarchical method would simply entail creating a bucket for each document and then merging them until the desired number of buckets is reached. This functionality is very similar to the existing Auto Date Histogram Aggregation, where buckets are created and then merged. Since bucket merging functionality was already created for that aggregation, this approach is significantly easier to implement. Furthermore, it seems that both methods can produce clusters of similar quality. https://www.cs.utah.edu/~piyush/teaching/4-10-print.pdf Please let me know if this line of reasoning makes sense :) |
@jamesdorfman Isn't Agglomerative Hierarchical Clustering expensive in terms time and space complexities compared to K-means? Agglomerative clustering: K-means: And since K-means has implementations that support incremental learning, the space complexity can be further reduced to make it constant. |
+1 |
Do we think this issue is still relevant? I see it's now 10 years ago that I first opened it. |
This brings back so many memories... |
Closing this as not planned in Aggregations. If we are going to develop this - it will go into ES|QL, where we are focusing future development. |
😢 |
Add k-means clustering to allow detection of clusters in data sets.
http://en.wikipedia.org/wiki/K-means_clustering
Would be useful for geo points but also other use cases too.
Thanks to https://github.com/koobs for suggesting this one in Sydney Elastic Training.
The text was updated successfully, but these errors were encountered: