Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Unsupervised Learning: K-Means Clustering Algorithm on Daily Price Parameters

Hey everyone,

I'm relatively new to this community, but I would like to share with you all a simple K-Means algorithm that takes pricing variables and learns labels in an unsupervised fashion. I am hoping the community can help improve the idea. I like unsupervised learning, and want to implement some more methods in this realm for stock data.

Because of the unsupervised learning, the means learned can act different ways. For example, in some tests, the means will act as binary switches, but in others, I can't decipher what it has learned.

Any comments, suggestions, or further reading/ideas would greatly be appreciated!

2 responses

Hey Hobey,

Thanks for sharing the algorithm - this is a promising idea. You may be able to simplify the code by using the k-means clustering methods built into scitkit-learn (documented here). For more unsupervised learning on Quantopian, check out Thomas Wiecki's post on Hidden Markov Models. To build on your work, you may want to consider implementing a mixture model or model with hierarchical clustering.

Ryan

Oh wow I didn't even know Quantopian had sklearn as a library! Thanks