How do you calculate the minimum circle within a cluster set of data points to potentially identify the ones that are most similar?
Mostra commenti meno recenti
I have made a PCA plot and I would like to calculate the minimum circle within a cluster set of data points to potentially identify the ones that are most similar, how can I do that?
Risposta accettata
Più risposte (2)
Image Analyst
il 13 Feb 2023
Modificato: Josh Natanson
il 14 Feb 2023
1 voto
You have the classes to which the cluster is assigned. But I'm not sure, for a particular cluster, what "the minimum circle within a cluster set of data points" means. Do you want to find the pair of points in each cluster that are closest to each other? Do you want to find the minimum containing/bounding circle for each cluster? Do you want the size of each cluster's bounding circle? Please clarify. How many PCs do you have? How many clusters do you have?
See

16 Commenti
Neo
il 13 Feb 2023
Image Analyst
il 13 Feb 2023
OK, so what happened when you used John's D'Errico's utility?
Neo
il 13 Feb 2023
Image Analyst
il 13 Feb 2023
I know I've told you this before but you don't seem to have done it or be taking it to heart so I'll ask again:
If you have any more questions, then attach your data and code to read it in with the paperclip icon after you read this:
Of course John didn't attach it. He may not even have opened up this discussion thread. You need to download it from the link I gave and call the function in your code (which you're still not sharing with me for some reason).
Neo
il 14 Feb 2023
Image Analyst
il 14 Feb 2023
OK, but again you have forgotten to attach your script (not my demo). From what we gather, it seems your script does (or attempt to do):
- You converted your original coordinates into PC coordinates.
- And then you did some kind of clustering on it in PC space - perhaps you used kmeans - I don't know.
- So now you have clusters and you want to extract each cluster individually and call John's min circle function.
So attach your code and data that does all that and we'll try to fix it. But, I'm not sure what a circle in PC space means. Like someone said in one of your other posts, PCs might make intuitive sense, but they might just be a bunch of weighted terms summed up with no intuitive meaning at all. Are you really sure you need to go to PC space to do your clustering and can't just do it in the original coordinate space?
Image Analyst
il 21 Feb 2023
You're plotting the y value of the data (a lot of values) versus the x value of only the centroids which is only 2 values. Not only do the sizes not match, but the concept doesn't even make sense. Explain in words what you are trying to plot with a black X marker.
Neo
il 21 Feb 2023
Neo
il 21 Feb 2023
Image Analyst
il 21 Feb 2023
Please attach your C, like in a .mat file with the paperclip icon.
Neo
il 21 Feb 2023
Neo
il 21 Feb 2023
Neo
il 22 Feb 2023
Neo
il 22 Feb 2023
Neo
il 22 Feb 2023
John D'Errico
il 14 Feb 2023
Modificato: John D'Errico
il 14 Feb 2023
1 voto
How many times will you ask the same question? You keep on talking about a minimal circle. Sometimes it is to draw a minimal circle. And sometimes you seem to be confusing different algorithms. (Why I pretty much gave up on responding to your posts. Sorry, but I did.) This time it is to use the minimal circle to identify a cluster of similar points, but you don't say how the cluster would be identified.
The problem is, your question does not seem to understand there are several issues here. If you have a cluster of points, you can trivially find the minimal bounding circle. But a mimimal bounding circle algorithm is not a clustering tool. So you cannot use that bounding circle code to find a cluster of points that you have not first identified.
I really am sorry, but it just seems as if you want to do something, but have no idea what is involved in doing what you want. So you just keep on asking the same question over and over again.
So, you have some points (currently in 2-d, the result of a PCA.) They may be pretty sparse, at least from the pictures drawn, which makes EVERYTHING more difficult. And what your eye sees are several groups of points. What you want is some automatic code that will draw a circle around the various clusters that your eye sees. This seems to be the gist of the last 3 or more questions that you have asked. The problem is, you need to use the tools we have been suggesting, at least if you want to do this in a way that is automatic.
First, perform a clustering analysis. There are MANY clustering algorithms available, but kmeans has some of the most commonly used tools.
Or, you could simply choose the clusters for any similar group of points yourself. For example, I have posted code on the file exchange (selectdata) that will allow a user to select groups of points using a lasso. Just draw a curve around the points in one group, and it will tell you which points they were. Or you can tell the code to use a circular shape, then you click on the figure, and expand that circle until it contains the points you want. The idea is, you surely know what you want to see. So do it using a mouse. But if not, then you NEED TO USE A CLUSTERING TOOL. A minimal bounding circle is not a tool for clustering.
Can I explain why a minimal bounding circle does not work as a tool for clustering? That might be a good question. The point is a bounding circle is almost always controlled by 3 points, and sometimes rarely only 2 points. If you drop one or more of those points, the minimal bounding circle changes dramatically. This makes the bounding circle rather an unstable thing, since it does not depend on any of the other data points inside the circle. And that means you cannot use it to perform clustering. You need to use some other scheme first. PLEASE READ AND UNDERSTAND THIS LAST PARAGRAPH. A bounding circle is not in itself a clustering tool, nor can it be made to work as one. At least not well.
Once you have the points identified in any one similar cluster, then use a tool as I have shown to find the circle and then draw it. I don't see the problem, or why this requires so many repeated questions on the topic.
Again, break down the problem into smaller ones. First you need to use clustering though. We dont know enoiugh about your problem to know which clustering scheme might be best, but very likely just selecting the points with a mouse might be the best.
2 Commenti
Neo
il 14 Feb 2023
But again, you cannot do that in any stable way. A minimal circle is a poor thing to identify a cluster of points, because that minimal circle is ALWAYS based on only a few points in any set. You really don't want to do exactly what it is you think you want to do. For example:
xy = randn(20,2);
[C,R] = minboundcircle(xy(:,1),xy(:,2))
t = linspace(0,2*pi,100);
plot(xy(:,1),xy(:,2),'bo',R*cos(t) + C(1), R*sin(t) + C(2),'-r')
axis equal
Do you see that only 3 points ALWAYS control the position and size of the circle? In some cases, only 2 points may control the circle. And if you were to delete one or more of those points, then the circle changes in a very unstable, totally unpredictable way. The rest of the points inside that circle have no impact at all on the circle itself.
You cannot use a minimal bounding circle to perform clustering. You CAN use it AFTER you have performed the clustering. But not to do the clustering itself. And I know that when you look at a set of points in a picture, you see a circle that contains them. So you think the circle can be made to do what you want. But your eye/brain combination can do many things that are exceedingly difficult to do using a computer, and to do it robustly.
Categorie
Scopri di più su k-Means and k-Medoids Clustering in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



