-1
$\begingroup$

I have 801 households (or customers). I have say 100 features on which I will describe a customer.

I have a feature map with me. I now apply K Means algorithm for the value of K say 6. I get 6 clusters as the output.

Now, I want to understand the unique household features describing these clusters. I have 7 demographic features of all these households.

How should I approach ? How to find dominating household features in all the clusters to understand why these households cluster this way ?

$\endgroup$
1
$\begingroup$

Your question is slightly unclear to me. I understand you have 100 individuals, measured across 7 variables, and clustered into 6 clusters(?) Now you want to see how these clusters compare by each variable.

Basic method to compare clusters using boxplots:

You can compare clusters by variables with boxplots. They should be organised like this: Each boxplot represents a variable, so there will be 7 boxplots. They have the 6 clusters along the X axis, and the quantity of that variable along the y axis.

To demonstrate, I'll generate some data to be clustered into 6 clusters (only 2 dimensions rather than your 7 for simplicity)

n = 1000
g = 8
set.seed(g)
d <- data.frame(x = unlist(lapply(1:g, function(i) rnorm(n/g, runif(1)*i^1.5))), 
            y = unlist(lapply(1:g, function(i) rnorm(n/g, runif(1)*i^1.5))))
plot(d)

Six clusters

Now we'll cluster it in R using the default kmeans function.

k <- kmeans(d, 6, nstart=25, iter.max=1000)
plot(comp, col=k$clust, pch=16)

Clustered

So now we want to compare the clusters across each variable (only 2 in this case). The first boxplot would be comparing the clusters by their x-values.

boxplot(d$x ~ k$cluster, xlab='Cluster', ylab='x-value')

X

And then you do it for the next variable, the y-values.

boxplot(d$y ~ k$cluster, xlab='Cluster', ylab='y-value')

Y

And yeah, you can compare the clusters visually. These boxplots in the pictures are meaningless but maybe you'll see that for 5 of your variables, the boxplots mostly overlap (so those variables hardly matter to the clustering), while there are 2 variables where the boxplots show little overlap (so those are the 2 variables that distinguish the households from each other).

There are more objective statistical methods for comparing the boxplots than just by looking too, you can find those by a quick search.

(Note, I gave the default R functions above to plot these, but I actually used ggplot for nicer looking plots)

n = 1000
g = 8
set.seed(g)
d <- data.frame(x = unlist(lapply(1:g, function(i) rnorm(n/g, runif(1)*i^1.5))), 
            y = unlist(lapply(1:g, function(i) rnorm(n/g, runif(1)*i^1.5))))
ggplot(d, aes(x, y)) + geom_point(size=3, alpha=0.7)

k <- kmeans(d, 6, nstart=25, iter.max=1000)
vggplot(d, aes(x, y)) + geom_point(alpha=.7, color=k$clust, size=3, pch = 16)

d$clust <- k$cluster

qplot(factor(clust), x, geom = "boxplot", data = d, xlab='Cluster', ylab='x-value') + geom_boxplot(aes(fill = factor(clust))) + theme(legend.position="NULL") 
| cite | improve this answer | |
$\endgroup$
0
$\begingroup$

To study the differences between clusters, compute models.

For example, a decision tree is easy to understand. Or you can select discriminative features. You could also try SVMs but these are not particularly easy to understand...

| cite | improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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