1
$\begingroup$

I have a dataset and I would like to see how the dataset is organized via a hierarchy.

I have thought of using a divisive method as follows:

1. Cluster the data into 2 classes using K-means (k=2)
2. Cluster Each of the 2 classes using K-means (with k=2) to create a total of 4 classes
3. And so on,

Would this be a good approach to constructing a dendogram for my data?

Another approach I have considered was

1. Create 15 clusters of my data
2. Cluster the 15 centroids into 5 classes
3. Cluster the 5 centroids into 2 classes

Then we can see a formed hierarchy for my data. Is this approach better?

$\endgroup$
3
  • $\begingroup$ why 15, 5 and 2? I personally prefer clustering into n-1 clusters, n-2, n-3 and so on... But we don't know enough about your data. $\endgroup$ Feb 19, 2014 at 15:26
  • $\begingroup$ Hey Expecto, I just said those k values just for example. I would definitely do it the way you suggested. $\endgroup$
    – A A
    Feb 19, 2014 at 15:40
  • $\begingroup$ This is generally not a good idea. Consider the data are really comprised of 3 clusters. How will you catch them three with your 2-then-each-in-2 k-means strategy? $\endgroup$
    – ttnphns
    Feb 19, 2014 at 17:19

2 Answers 2

2
$\begingroup$

The straightforward approach is to use the hierarchical clustering see wikipedia and hclust function in R. This allows to form hierarchy as well as to see the influence of the different linkages and distance metrics. Also, it is worth noting that there are many good alternatives to kmeans, see for example mclust package

$\endgroup$
7
  • $\begingroup$ I'm actually using Python! Would you happen to know of a method such as hclust available in packages such as scikit-learn? $\endgroup$
    – A A
    Feb 19, 2014 at 15:41
  • 2
    $\begingroup$ @AA In Python: scipy.cluster.hierarchy (example1, example2). Or to be more precise, use scipy.cluster.hierarchy.linkage with method='centroid', to get "hierarchical k-means" (though, 'average' and 'weighted' may by similar). $\endgroup$ Feb 19, 2014 at 15:57
  • $\begingroup$ Thanks for your help! however i seem to get ValueError: Valid methods when the raw observations are omitted are 'single', 'complete', 'weighted', and 'average'. when I use centroid as the method $\endgroup$
    – A A
    Feb 19, 2014 at 17:02
  • $\begingroup$ I am afraid I can't help you with python, but if you google "hierarchical clustering python", you will get many results to start with. $\endgroup$
    – df239
    Feb 19, 2014 at 18:08
  • 1
    $\begingroup$ @AA Strange - it is in the documentation. Either you have some old version of SciPy, or something else is wrong with the code (BTW: Could you please use @PiotrMigdal, otherwise I may miss it.) $\endgroup$ Feb 20, 2014 at 15:59
1
$\begingroup$

I believe it may be better and easier to use a method/tool that is hierarchical than manually doing this yourself.

A good example of this is the tree library in R. Check out Jeffrey Leek's lesson on Predicting with trees.

Here's a good R code example from Dr. Leek's lesson:

data(iris)
install.packages('tree')
library(tree)
tree1 <- tree(Species ~ Sepal.Width + Petal.Width, data=iris)
plot(tree1)
text(tree1)

Output: enter image description here

$\endgroup$
2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.