Machine Learning Recipes in Kotlin
280 pages
English
PDF
4.5

Machine Learning Recipes in Kotlin

Machine Learning Recipes in Kotlin

Author:

Year:

Summary:

Introduction

The book "Kotlin ML Recipes" (author — Ajay Balamurugadas, 2022, 280 pages) is a collection of practical solutions for machine learning tasks implemented in the Kotlin language. Unlike many books focused on Python, this publication fills a niche for developers working in the JVM ecosystem and preferring Kotlin for its conciseness, safety, and compatibility with Java. The book was published by Apress and is aimed at engineers who want to integrate ML models directly into production code without switching to other languages.

What the book is about

"Kotlin ML Recipes" is not a theoretical textbook on statistics or algorithms, but a practical guide in a "recipes" format. Each chapter contains specific tasks, step-by-step instructions, and ready-to-use code. The author covers the complete data workflow: from loading and preprocessing to model training, evaluation, and deployment. Key topics include:

  • Working with Kotlin libraries for ML (Koma, Smile, KotlinDL, Deep Learning for JVM);
  • Integration with popular Java frameworks (Weka, Deeplearning4j, TensorFlow Java);
  • Classic algorithms: linear regression, decision trees, random forest, SVM;
  • Neural networks and deep learning using KotlinDL;
  • Text processing and NLP (tokenization, TF-IDF, Word2Vec);
  • Working with images and convolutional networks;
  • Model serialization and export to ONNX;
  • Deploying models as REST services on Ktor.

Who this book is for

The book is intended for Kotlin developers with a basic knowledge of the language who want to learn machine learning without switching to Python. It will also be useful for Java programmers transitioning to Kotlin, and data scientists looking to move their pipelines to the JVM stack. It is assumed that the reader is familiar with the basics of ML (what supervised learning is, quality metrics), but does not necessarily have experience implementing models in Kotlin.

What the reader will learn

  • How to set up an environment for ML projects in Kotlin (Gradle, dependencies);
  • How to load and clean data using Kotlin idioms (sequences, extension functions);
  • How to implement 10+ classic machine learning algorithms "from scratch" and using libraries;
  • How to build and train neural networks with KotlinDL;
  • How to process text and images for ML tasks;
  • How to evaluate models (cross-validation, confusion matrix, ROC-AUC);
  • How to save trained models and load them into production;
  • How to create a REST API for a model on Ktor.

Strengths

The main advantage of the book is its practical focus. Each recipe is accompanied by complete code that can be immediately copied and run. The author pays attention to common mistakes and ways to avoid them. The book is well-structured: from simple examples to complex ones, from classics to deep learning. The chapter on deployment deserves special mention — it's rare for ML books on the JVM. Additionally, the code is written in a modern Kotlin style (without unnecessary Java constructs), making it pleasant to read.

Who it is recommended for

I recommend this book to all Kotlin developers who want to expand their skill set with machine learning, as well as to teams building ML services on the JVM. It is also suitable for students learning Kotlin and wanting to apply it in data science. If you already know Python ML but work on a Kotlin project — this book will save you hours of searching for information.

However, it's worth noting that the book does not replace fundamental courses in statistics or algorithms — it is specifically about implementation. Beginners in ML may need to study theory in parallel.

Overall, "Kotlin ML Recipes" is a high-quality, timely publication that fills an important gap in the literature on Kotlin. Rating: 8/10.

Recommendations