Hello,
Doubt: The first line in the attached image says that c (i) is the index of cluster to which example x(i) is currently assigned. But a cluster (c) can have many data points then how same i for c is possible for a data point i ?
Hello,
Doubt: The first line in the attached image says that c (i) is the index of cluster to which example x(i) is currently assigned. But a cluster (c) can have many data points then how same i for c is possible for a data point i ?
Another thing is that in the Cost Function how c(i) is taken from 1 to m ? because as c represents a cluster and we have only k clusters not m ?
‘m’ is correct.
Cost is computed all examples, using the distance from its assigned centroid.
@TMosh Thanks for the reply but c represents a cluster. And k < m. So, how is it possible ?
@paulinpaloalto Hello, Sir. Need your help here.
Hi @abhinavtyagi ,
We could have m number of data points (examples), let say 1000, and group them into k number of clusters, say 50. That is how k < m.
Please read my reply carefully.
The point is that c^{(i)} is the index of the cluster to which the i-th sample is assigned. So the value of c^{(i)} is a number between 0 and k-1, but there are m such values: one for every sample, right?
Hello @Kic, I get that k<m, but my point of confusion is that in cost function J, c is taken from 1 to m but c represents index of cluster. As in your example we’ve 50 clusters so i can be from 1 to 50. not 1 to m. Then, why c is from 1 to m in cost function ?
Please see my immediately previous post …
ok ok, I think I understand it now. Since a single cluster contains multiple data points, the cost function considers every data point from every cluster while computing the total cost.
So, it’s like we’re unpacking each cluster vector in our cost function to compute the cost.
Am I now thinking in the right direction ?
A cluster is defined by a set of points. If you want to call that a “vector” of points, it’s a vector of vectors, right? You can represent it as a matrix, although the matrix for each cluster may have a different number of samples.
Better to consider a cluster as a list of examples. Rather than as a vector.
{moderator edit - quiz question image removed}
Please take a look at this exercise.
How option 1 and option 2 can be true at the same time ?
If c⁽ⁱ⁾ represents the index of a cluster, and if K=3 that means c⁽ⁱ⁾ can be either 1 or 2 or 3.
Yes, those two statements are both true. You’re still missing the point I made in my first post on this thread. The question is the values of c^{(i)} versus how many instances of those values there are.
Also please note that we aren’t supposed to show quiz questions and answers on a public thread, so I will edit your post to remove the image.
Umm, Yes a cluster is basically a set of points.
So, if a data point is like x⁽ⁱ⁾=[2.3,4.1]. Then, matrix can be defined as a vector of vectors something like:
C⁽ⁱ⁾ = [
[2.3, 4.1],
[3.2, 5.0],
[1.1, 3.3]
]
okay, thanks a lot. Let me understand that first.
Also please note that we aren’t supposed to show quiz questions and answers on a public thread, so I will edit your post to remove the image.
I’ll take care.
Suppose we have 10 samples, so that m = 10. Further suppose that we have only two clusters. If samples 1, 5 and 7 are the only ones in the first cluster, then here is what the c array will be:
c = [1, 2, 2, 2, 1, 2, 1, 2, 2, 2]
So we have c[8] = 2 and c[5] = 1. Note that I’m doing mathematical style indexing there with the indexes from 1 to m. If we were actually writing the code in python, then we’d be using “zero-based” indexing of course.
@paulinpaloalto Hello, Sir
I understood it now.
The value of c⁽ⁱ⁾ ∈ {1,2,…,K} But i ∈ {1,2,…,m} that depends on the number of examples we have.
Thank you so much.