# how to determine the certain number of clusters your data contain? [duplicate]

I was wondering if I can find a certain way that show me the number of clusters my data has by its nature.I don't want to find the optimal number of clusters for clustering, I want to know the number of clusters my data has by its nature not what i wanted it to be.

Any little help would be greatly appreciated.

• Can you clarify the distinction between "the optimal number of clusters for clustering", & "the number of clusters my data has by its nature"? I can't tell what the difference b/t those 2 are, & the question cannot be answered w/o that being clear. Nov 1, 2017 at 15:16
• @GUNG:YES, There is difference between these two concepts.According to: sthda.com/english/articles/29-cluster-validation-essentials/… We can apply a clustering method on a random uniformly distributed data and in the result see some clusters even if there are no meaningful clusters present in it.So the ways have been used to evaluate the optimal number of k indicate us the number of clusters I wanted the data to have not what it has by its nature.
– far
Nov 4, 2017 at 5:44

To be honest, without perfect divine knowledge from the Norse God of Statistics, there isn't a way to know with 100% certainty just how many clusters your original data may have had from a sample alone. However, because this answer seems like a cop-out, here is an educated opinion:

There are two options that quickly spring to my mind:

If you have a guess for a range of clusters you expect, then you can repeatedly apply $k$-means clustering to minimise some form of cross-validated error rate (if you have a gold standard data set or a training set you trust).

However, if you are performing exploratory data analysis and have no idea how many clusters you may have, I would read about Agglomerative and Divisive Hierarchical Clustering. Here is a data mining lecture that discusses these options with a little more detail: http://www.stat.cmu.edu/~ryantibs/datamining/lectures/06-clus3.pdf

EDIT

As pointed out in the comments, there is "no such thing as $k$-nearest neighbours clustering", so I have corrected my statement. To better better see the difference between $k$-means (clustering) and $k$-nearest neighbours (classification), see this Quora discussion.

• There is no k nearest neighbor clustering. Nov 2, 2017 at 6:43
• @Gabriel J.Odom:Thank you for your response but as I mentioned in the gung's response , I don't want to find the optimal number of k.
– far
Nov 4, 2017 at 5:50

The first step will be to determine a reasonable way of measuring the distance between any two points.

Normalizing your data will help with this.

Most clustering algorithms rely on the Euclidean distance between vectors. However, there is no reason to believe that two data points with small Euclidean distance are actually similar conceptually. This is the goal you want to achieve. Try weighting your features in different ways before clustering.

The next step is to visualize your data using dimension reduction. Try techinques like t-SNE or diffusion maps. These techniques will compress the information in the data set and leave you with its general features, including its structure as a collection of clusters.

• My data has 35 variables which includes categorical and continuous.I use "gower" distance measure.I want to use FAMD(factor analysis of mixed data) as a dimenstion reduction approach.
– far
Nov 4, 2017 at 5:37