News for hackers. Stuff that matters.
Re:K-Means Clustering by staticautomatic on Friday January 12, 2024 @08:38PM (#38976513)
What are people using k-means for? I can count on one hand the number of times I’ve had a good a priori rationale for the value of k.
Re:K-Means Clustering by magicalhippo on Saturday January 13, 2024 @12:21AM (#38977554)
I implemented an algorithm which used k-means to reduce noise in a path tracer.

For each pixel instead of a single color value it generated k mean color values, using an online algorithm. These were then combined to produce the final pixel color.

The idea was that a pixel might have several distinct contributions (ie from different light sources for example), but due to the random sampling used in path tracing the variance of sample values is usually large.

The value k then was chosen based on scene complexity. There was also a memory trade-off of course, as memory usage was linear in k.

Re:K-Means Clustering by le-mark on Saturday January 13, 2024 @07:09AM (#38979257)
> For each pixel instead of a single color value it generated k mean color values, using an online algorithm.

What does online mean here?

Re:K-Means Clustering by magicalhippo on Saturday January 13, 2024 @02:29PM (#38983607)
Online means it processes the items as they come[1]. This means the algorithm can't consider all the items at once, and has to try to be clever on the spot.

In my case the algorithm uswd would use the first k samples as the initial means, and would then find which of the k means were closest to the current sample, and update that mean[2].

Given that in parh tracing one would typically use a fairly large number of samples per pixel relative to k, this approach did a reasonable job of approximating the k means.

[1]: https://en.wikipedia.org/wiki/Online_algorithm

[2]: https://yokolet.com/2017/05/29/online-algorithm.html

Re:K-Means Clustering by hansvm on Friday January 12, 2024 @11:26PM (#38977325)
The kmeans metric is exactly the metric you would want to optimize the performance of an algorithm like [bolt](https://arxiv.org/abs/1706.10283). In that and other discretization routines, the value of k is a parameter related to compression ratio, efficiency, and other metrics more predictable than some ethereal notion of how many clusters the data "naturally" has.
Re:K-Means Clustering by web9ed on Friday January 12, 2024 @10:06PM (#38976965)
I would recommend checking out DBSCAN as it is similar without having to provide a number k https://en.m.wikipedia.org/wiki/DBSCAN
Re:K-Means Clustering by Konnstann on Friday January 12, 2024 @10:30PM (#38977083)
I've used something similar for tissue segmentation from hyperspectral images of animals where I know there should be K different tissue types I care about.
Re:K-Means Clustering by derwiki on Friday January 12, 2024 @08:59PM (#38976642)
Used it in college to downscale an X color image to Y number of colors. Sure, Photoshop does it, but it was informative to do it manually.
Re:K-Means Clustering by refulgentis on Friday January 12, 2024 @09:18PM (#38976728)
Google's Material You uses this to initiate color theming

(n.b. Celebi's, note usage of Lab / notHSL, respect Cartesian / polar nature of inputs / outputs, and ask for high-K, 128 is what we went with but it's arbitrary. Can get away with as few as 32 if you're ex. Doing brand color from favicon)

Re:K-Means Clustering by girvo on Friday January 12, 2024 @09:50PM (#38976882)
Ooh this is a much nicer approach than the kind of brute force approach we took at work for theme gen
Re:K-Means Clustering by dhosek on Friday January 12, 2024 @09:59PM (#38976928)
I did a modified version of this once for a map of auto dealerships, although rather than working with a fixed k, I used a fix threshold for cluster distance. The algorithm I was working with had O(n³) complexity so to keep the pregeneration of clusters manageable, I partitioned data by state. The other fun part was finding the right metric formula for measuring distances. Because clusters needed to correspond to the rectangular view window on the map, rather than a standard Euclidean distance, I used d = max(Δx,Δy) which gives square neighborhoods rather than round ones.
Re:K-Means Clustering by sshumaker on Friday January 12, 2024 @09:07PM (#38976677)
Sometimes you can use a heuristic to estimate K, or use a variant that terminates at some distance threshold.

That said, something like hdbscan doesn’t suffer from this problem.

Re:K-Means Clustering by bagels on Friday January 12, 2024 @09:04PM (#38976669)
Measuring multiple physical objects with the same sensor, you can use k-means to separate the measurements from each object, given that you know how many objects are being sensed. I can't get more specific than that.
Re:K-Means Clustering by tim-fan on Saturday January 13, 2024 @04:32AM (#38978427)
Sounds like you're describing my carpet-color classification project! [1]

Built as part of a larger carpet based localisation project [2]

1: https://nbviewer.org/github/tim-fan/carpet_color_classificat...

2: https://github.com/tim-fan/carpet_localisation/wiki/Carpet-L...

Re:K-Means Clustering by missingrib on Friday January 12, 2024 @10:52PM (#38977200)
I've used it for identifying dominant colors in images.
Re:K-Means Clustering by minimaxir on Friday January 12, 2024 @09:18PM (#38976723)
k-means is good for fast unsupervised clustering on an unknown low-dimensional dataset. It's helpful for EDA.

If you want accuracy at an order of magnitude more compute, you can use something like DBSCAN.

Re:K-Means Clustering by theophrastus on Friday January 12, 2024 @08:53PM (#38976610)
Additional small molecule pharmaceutical candidates via molecular descriptors
Re:K-Means Clustering by trc001 on Friday January 12, 2024 @08:40PM (#38976522)
Real estate price estimates would be the classic, and frankly still common, example
Re:K-Means Clustering by icelancer on Friday January 12, 2024 @09:26PM (#38976758)
Baseball pitch types based on physics profiles.
Re:K-Means Clustering by calvinmorrison on Friday January 12, 2024 @10:01PM (#38976939)
We used k means clustering on a project used to track fruit fly memory and learning behaviors

http://git.ceux.org/FlyTracking.git/

Re:K-Means Clustering by dilyevsky on Friday January 12, 2024 @08:56PM (#38976628)
data segmentation (e.g Voronoi), grouping (like search query results), anomaly detection. lots of different things
Re:K-Means Clustering by jncfhnb on Friday January 12, 2024 @09:37PM (#38976814)
K is 3.

It’s honestly fine for just finding key differences like a principal component for light storytelling. They don’t need to be distinct clusters

Re:K-Means Clustering by Waterluvian on Friday January 12, 2024 @09:01PM (#38976656)
Constantly in remote sensing and GIS work.
Re:K-Means Clustering by JackeJR on Friday January 12, 2024 @08:52PM (#38976598)
SMOTE
Re:K-Means Clustering by brianleb on Friday January 12, 2024 @08:59PM (#38976639)
So after re-reading your comment a few times, I am left with this thought: either you don't understand what k-means clustering is, or I don't understand what k-means clustering is. I wouldn't describe myself as a machine learning expert, but I have taken some grad level classes in statistics, analytics, and methods like this/related to this.

So my question is... could you elaborate?

Re:K-Means Clustering by dilippkumar on Friday January 12, 2024 @09:05PM (#38976670)
Not GP, but I understood their question as follows.

Assume you collect some kindergartners and top NBA players into a room and collect their heights. Now say you pass these to two hapless grad students and ask them to perform K-means clustering.

Suppose one of the grad students knew the composition of the people you measured and can guess these height should clump into 2 nice clusters. The other student who doesn't know the composition of the class - what should they guess K to be?

I understood the GP's comment to refer to the state of the second grad student. How useful is K-means clustering without knowing K in advance?

Re:K-Means Clustering by bjornbsm on Saturday January 13, 2024 @03:32AM (#38978201)
>I understood the GP's comment to refer to the state of the second grad student. How useful is K-means clustering without knowing K in advance?

There are several heuristics for this. Googling I see that the elbow method, average sillhouette method and gap statistic method is the most used.

I think you could play around with your own heuristics as well. Simple KDE plots showing the amount of peaks. Maybe, say the variance between clusters should be greater than the variance inside any cluster could maybe work. (Edit: this seems to be the main point of the average sillhouette method).

Re:K-Means Clustering by esafak on Friday January 12, 2024 @09:43PM (#38976848)
The first problem is picking k. The second problem is the definition of distance or, equivalently, the uniformity of the space. Naively using the Euclidean distance in an embedding where similarity is non-uniform leads to bad outcomes. This problem is solved by learning a uniform embedding, and this is much harder than running k-means.

k-means assumes these hard parts of the problem are taken care of and offers a trivial solution to the rest. Thanks for the help, I'll cluster it myself.

Re:K-Means Clustering by bagels on Friday January 12, 2024 @09:02PM (#38976660)
You have to choose the number of clusters, before using k-means.

Imagine that you have a dataset, where you think there are likely meaningful clusters, but you don't know how many, especially where it's many-dimensioned.

If you pick a k that is too small, you lump unrelated points together.

If k is too large, your meaningful clusters will be fragmented/overfitted.

There are some algorithms that try to estimate the number of clusters or try to find the k with the best fit to the data to make up for this.

Re:K-Means Clustering by keenmaster on Friday January 12, 2024 @09:21PM (#38976739)
Couldn’t you make some educated guesses and then stop when you arrive at a K that gives you meaningful clusters that are neither too high level nor too atomized.
Re:K-Means Clustering by yarg on Friday January 12, 2024 @11:57PM (#38977455)
Probably not the best in terms of efficiency.

Easier just to deliberately overshoot (with a too high k) and then merge any clusters with too much overlap.

Re:K-Means Clustering by boredemployee on Friday January 12, 2024 @08:40PM (#38976521)
knowledge graphs
Re:K-Means Clustering by tomnipotent on Saturday January 13, 2024 @01:36AM (#38977818)
Frequently used in e-commerce, such as RFM clustering for targeted marketing.
Re:K-Means Clustering by patcon on Saturday January 13, 2024 @01:54AM (#38977884)
Polis (and Twitter's community notes, I believe)

Participation At Scale Can Repair The Public Square https://www.noemamag.com/participation-at-scale-can-repair-t...

Polis: Scaling deliberation by mapping high dimensional opinion spaces https://scholar.google.com/scholar?q=Polis:+Scaling+delibera...

Restricting clustering to 2-5 groups impacts group aware/informed consensus and comment routing https://github.com/compdemocracy/polis/issues/1289