“assorted berries” by William Felker on Unsplash

Segmentation, recommendation and marketing optimization algorithm in 24 lines of code

Have you ever thought how do recommendation systems work, how to prepare an interpretable segmentation or optimize your marketing campaign target group? I have good news for you! After reading this article, you will know the answer to all of these questions on a fundamental level. Let me introduce you to Non-negative matrix factorization (NMF) algorithm.

This algorithm is used in a vast number of fields including image processing, text mining, clustering, collaborative filtering, and community detection. Its most significant assets are speed, ease of interpretation and versatility.

The article is intended to be an introductory one into NMF and recommendation systems. In the first part, you can find some theory behind the algorithm. The next one is a walk-through a toy example of segmentation, recommendation, and marketing optimization. The subsequent part consists of some projects examples where NMF could be useful. The last part contains a list of sources I gathered while writing this article and Python code used to prepare the toy example.