A Kindle recommendation engine

Your next favourite book is already leaving clues.

Millions of books compete for one small screen. This project listens to the traces readers leave behind, then chooses a different recommendation strategy for different kinds of readers.

Follow the clues
One readerMany possible journeys
Signals gatheredReviews
price
time
taste
ResultLess searching.
More reading.
The recommendation changes as the reader changes.That is where the story begins.
Why it matters

A bookshelf should feel smaller, without making possibility smaller.

For readers

Relevant suggestions reduce choice overload and help a reader reach a promising book faster.

For Kindle

Better discovery can strengthen engagement, conversion and the feedback loop that improves future recommendations.

For trust

The project does not pretend every reader behaves alike. It uses distinct strategies for distinct patterns, while keeping the system measurable and reproducible.

Now we open the machine

From a reading clue to an ML decision

The first two sections explain why recommendations matter. From here, each chapter introduces one technical idea only after showing the reader-facing reason for it.

Machine learning begins with representation

Turn behaviour into features a model can compare

A model cannot directly understand that somebody is adventurous, price-conscious or returning after a long pause. The pipeline represents those ideas with measurable features such as category diversity, total spend, purchase count, ratings, price and time.

FeatureA measurable signal supplied to a model.
EmbeddingA dense numerical map where similar books sit closer together.
InferenceUsing a trained model to produce a recommendation.
Three-dimensional Gaussian Mixture Model cluster visual using diversity, spending and purchases
Soft clustering gives each reader probabilities rather than forcing every reader into a rigid box.
AI decides which specialist should listen

Clustering is the router, not the final recommendation

A Gaussian Mixture Model estimates behavioural membership from diversity, spending and purchase volume. The dominant pattern routes the reader to a specialised model. Mixed membership still matters because a reader may display both frugal and selective behaviour.

Unsupervised MLGMM discovers behavioural structure without pre-labelled reader types.
Supervised and sequential MLLSTM and BERT4Rec learn patterns from ordered interactions.
Decision learningBandit logic balances reliable choices with controlled exploration.
Mapping from behavioural clusters to specialist recommendation models
The routing layer selects one of five ML models: LSTM, BERT4Rec, Random Walk, Multi-Armed Bandit, or Hybrid ALS plus CBF.
Deep learning for sequence context

BERT4Rec learns by hiding a book, then predicting it

For selective readers, the order and surrounding context of books is informative. BERT4Rec masks selected items in a reading sequence and uses bidirectional self-attention to reconstruct them. Book, category and position embeddings are combined before the Transformer layers.

Gentle definition: attention is a learned weighting mechanism. The model assigns more influence to the earlier and later books that are most useful for understanding a missing item.
BERT4Rec architecture with embeddings, Transformer layers and masked-item prediction
BERT4Rec is used for selective spenders whose sparse, diverse histories need richer context.
AI needs data engineering to stay useful

Training and serving are separated, then joined in a loop

Airflow schedules heavy batch work. BigQuery stores historical data. Kafka and Socket.IO carry current interactions. SQLite provides a lightweight serving view. MLflow tracks versions, parameters, metrics and artefacts so a model can be compared, reproduced or rolled back.

The important distinction: the AI models choose and rank books. The surrounding data platform makes those choices current, observable and deployable.
Architecture connecting BigQuery, Airflow, SQLite, machine learning models, MLflow and Socket.IO
The hybrid architecture joins scheduled retraining to responsive recommendation delivery.
The final moment is still human-facing

Models return ranked books, not an explanation of mathematics

The front end receives a shortlist and presents it as a browsable shelf. Behind each card is a chain of captured interaction, feature preparation, reader routing, model inference and delivery. The interface keeps that complexity out of the reader's way.

The system then records new interactions, allowing later retraining to react to changing preferences. This closes the recommendation loop.

Front-end architecture showing browser, Flask, Kafka, model selection and recommendation delivery
The serving path converts model output into a real-time web experience.
Choose your depth

Start with the idea. Stay for the machinery.

Each tab opens another layer. The same question returns throughout: what should Kindle show this reader next?

The problem
A tiny screen.
A vast store.

When choice becomes friction, even a good book can disappear. The system turns behaviour and book information into a ranked path forward.

What happens behind one suggestion?

●
Listen
Capture ratings, purchases, reviews, price, categories and time.
◆
Understand
Estimate the reader's behavioural segment without forcing hard boundaries.
↗
Route
Send the reader to the model designed for that pattern.
✓
Learn
Log outcomes, monitor models and retrain as preferences change.

The complete five-model routing rule

L
Frugal shoppers → LSTM
Uses ordered histories and explicit price signals.
B
Selective spenders → BERT4Rec
Uses bidirectional attention for sparse and diverse reading sequences.
R
New or dormant customers → Random Walk
Uses limited anchor books to traverse related paths with controlled exploration.
M
Premium and loyal customers → Multi-Armed Bandit
Uses 95% exploitation and 5% exploration for confident but refreshed recommendations.
H
Completely new customers → Hybrid ALS plus CBF
Begins with book content when history is absent, then adds collaborative evidence as interactions accumulate.