Blog

Notes on the .Net ecosystem, Angular, Software Architecture, Machine Learning and CyberSecurity

← All posts
Building a rock recommender with ML.NET
5 articles

Building a rock recommender with ML.NET

A five-part series building a rock music recommendation engine from scratch, in .NET, with no Python anywhere. Content-based suggestions for new users, a collaborative model trained with ML.NET once feedback exists, and a real API backed by MongoDB.

What you'll learn

  • The difference between content-based and collaborative recommendations, and how to solve the cold-start problem
  • How to actually measure whether a recommender is good, with Precision@K, Recall@K and NDCG
  • How to train a collaborative-filtering model with ML.NET's MatrixFactorizationTrainer
  • How to evaluate a trained model with a leave-one-out test, not just trust the training run
  • How to wire a trained model into a real ASP.NET Core API with Clean Architecture and MongoDB

Articles in this series

Recommendation systems: how Spotify knows what you want to hear

This article opens a new series here on the blog, and its destination is very practical: building, from scratch, a rock music recommendation API, similar to what Spotify and Deezer do, with everything running on .NET. But the real subject of the series is not just building a recommender that works, it is understanding, in depth, how to know if it works well.

How to evaluate a recommendation model

Second article in the rock recommender series. In the first one, we saw how a machine decides what to recommend. In this one, I answer the question that closes that article: how do we know these recommendations are actually good? Calmly, and with a numeric example of every metric.

Building the dataset and training the recommender with ML.NET

Third article in the rock recommender series. The theory from the first two articles (types of recommendation, cold start and the evaluation metrics) now becomes code. Let's build our catalog of bands and songs and train the first model, using ML.NET.

Evaluating the model in practice

Fourth article in the rock recommender series. We trained a model in the previous article, but training is not the same as getting it right. Now we apply, with code, the metrics explained in article 2 (Precision@K, Recall@K and NDCG) on that model, to honestly answer: is it good?

Building the rock recommender API

Fifth and last article in the series. After training and evaluating the model, it's time to put everything inside a real API, with MongoDB keeping each person's history and simple endpoints to pick bands, ask for the next song and give a like or dislike. The full code is open on GitHub, in the RockRecommender repository.