Diversification in stock portfolio is always desired to minimize the risk. One of the many ways is to cluster these stocks into many categories in which each category exhibits similar behavior.
Here are a few categories I identified with some stocks by applying simple clustering algorithm.
Category 1
Category 2:
Category 3:
Category 4:
In the experiment, I tried with different number of clusters and calculated its corresponding cost. See the following chart, I chose 15 as the ideal number of clusters to cluster 93 stocks I have in the portfolio.
The main goal of this exercise is to build a balanced portfolio with combination of stocks from different categories to minimize risk.