<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/how-ml-decides-the-next-best-action-building-a-recommendation-system-at-scale-1huilcpcj" -->

---
title: How ML Decides the Next Best Action: Building a...
description: An in-depth walkthrough of building a Next Best Action (NBA) recommendation system for a payments platform, covering the full pipeline from raw transactional...
canonical: https://daily.dev/posts/how-ml-decides-the-next-best-action-building-a-recommendation-system-at-scale-1huilcpcj
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: How ML Decides the Next Best Action: Building a Recommendation System at Scale | daily.dev
og:description: An in-depth walkthrough of building a Next Best Action (NBA) recommendation system for a payments platform, covering the full pipeline from raw transactional...
og:url: https://daily.dev/posts/how-ml-decides-the-next-best-action-building-a-recommendation-system-at-scale-1huilcpcj
og:image: https://api.daily.dev/og/posts/1hUilCpCj.png
og:image:alt: How ML Decides the Next Best Action: Building a Recommendation System at Scale
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# How ML Decides the Next Best Action: Building a Recommendation System at Scale

**[Medium](https://daily.dev/sources/medium_js)** · 13 min read · 0 upvotes · 0 comments

## Summary

An in-depth walkthrough of building a Next Best Action (NBA) recommendation system for a payments platform, covering the full pipeline from raw transactional data to personalized offers. Topics include distributed feature engineering with PySpark, RFM (recency/frequency/monetary) and temporal signals, building training datasets with proper negative-label handling and avoiding data leakage, using XGBoost for scoring, separating ML prediction from business rules and ranking, candidate generation for scale, AWS orchestration (EventBridge, Lambda, SageMaker), batch vs real-time inference trade-offs, evaluation metrics beyond accuracy (Precision@K, Hit Rate), incrementality/uplift modeling, exploration-exploitation trade-offs, and common production challenges like data skew, class imbalance, cold start, and model drift.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://medium.com/@bilalkhan_26063/how-ml-decides-the-next-best-action-building-a-recommendation-system-at-scale-fa928f6902ce>

## Questions this post answers

### Why is a negative label in a recommendation dataset not necessarily a negative preference?

A zero label can mean the customer never saw the offer, saw but ignored it, wasn't eligible, didn't transact during the campaign window, or the offer wasn't relevant at that time, rather than genuine dislike. Recommendation datasets require careful label definition because conflating these cases with true negative preference biases the model's learned relationships between customers and actions.

_Anyone debugging biased recommendation labels can find grounded architecture patterns like this on daily.dev._

### Why does uplift modeling matter more than response probability in a coupon recommendation system?

A customer predicted to redeem a coupon may have transacted anyway, meaning the coupon created no incremental value, while another customer with the same predicted probability might only transact because of the coupon. Uplift modeling and causal inference target this difference, answering who should receive an offer because it will actually change their behavior, not just who is likely to respond.

_Teams weighing uplift modeling against plain classification can compare real-world tradeoffs on daily.dev._

### Why would a production recommendation system use batch inference instead of real-time scoring?

Batch inference can generate recommendations for millions of customers ahead of time and store them for retrieval when the app opens, which is simpler and more cost-efficient than scoring every request live. Whether to choose batch or real-time depends on latency requirements, data freshness needs, traffic volume, cost, model complexity, and business SLA constraints.

_Engineers deciding between batch and real-time ML serving can weigh these tradeoffs on daily.dev._

## Similar posts on daily.dev

- [From Prediction to Action: How to Turn AI Outputs Into Decisions](https://daily.dev/posts/from-prediction-to-action-how-to-turn-ai-outputs-into-decisions-dq1u6hyfr) · Salesforce Engineering · 3 upvotes · 0 comments
- [Generative AI for Recommendations: what YouTube, Netflix and Meta are Moving to, Built From Scratch](https://daily.dev/posts/generative-ai-for-recommendations-what-youtube-netflix-and-meta-are-moving-to-built-from-scratch-jpbxplzky) · Medium · 1 upvotes · 0 comments
- [Our Early Journey to Transform Instacart’s Discovery Recommendations with LLMs](https://daily.dev/posts/our-early-journey-to-transform-instacart-s-discovery-recommendations-with-llms-wpv1ryxzx) · Instacart · 1 upvotes · 0 comments
- [6 Steps to Build an ML Model](https://daily.dev/posts/6-steps-to-build-an-ml-model-bv51m79fz) · Daily Dose of Data Science \| Avi Chawla \| Substack · 5 upvotes · 0 comments
- [Building Real-Time Recommendations with Snowflake Online Feature Serving — Two-Tower Networks](https://daily.dev/posts/building-real-time-recommendations-with-snowflake-online-feature-serving-two-tower-networks-mqwgcqwal) · Snowflake Community · 1 upvotes · 0 comments

---

Tags: [#recommendation-systems](https://daily.dev/tags/recommendation-systems), [#feature-engineering](https://daily.dev/tags/feature-engineering), [#xgboost](https://daily.dev/tags/xgboost), [#pyspark](https://daily.dev/tags/pyspark)

[View this post on daily.dev](https://daily.dev/posts/how-ml-decides-the-next-best-action-building-a-recommendation-system-at-scale-1huilcpcj)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"How ML Decides the Next Best Action: Building a Recommendation System at Scale","url":"https://daily.dev/posts/how-ml-decides-the-next-best-action-building-a-recommendation-system-at-scale-1huilcpcj","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/how-ml-decides-the-next-best-action-building-a-recommendation-system-at-scale-1huilcpcj"},"datePublished":"2026-09-12T16:12:26.777Z","dateModified":"2026-09-12T16:25:48.601Z","description":"An in-depth walkthrough of building a Next Best Action (NBA) recommendation system for a payments platform, covering the full pipeline from raw transactional...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/bc3f0ef1d8db002dc7729cd198e203bd?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/bc3f0ef1d8db002dc7729cd198e203bd?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Medium","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Medium","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/medium","url":"https://daily.dev/sources/medium_js"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/how-ml-decides-the-next-best-action-building-a-recommendation-system-at-scale-1huilcpcj","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"recommendation-systems,feature-engineering,xgboost,pyspark","timeRequired":"PT13M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Medium","item":"https://daily.dev/sources/medium_js"},{"@type":"ListItem","position":3,"name":"How ML Decides the Next Best Action: Building a Recommendation System at Scale"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/how-ml-decides-the-next-best-action-building-a-recommendation-system-at-scale-1huilcpcj#faq","mainEntity":[{"@type":"Question","name":"Why is a negative label in a recommendation dataset not necessarily a negative preference?","acceptedAnswer":{"@type":"Answer","text":"A zero label can mean the customer never saw the offer, saw but ignored it, wasn't eligible, didn't transact during the campaign window, or the offer wasn't relevant at that time, rather than genuine dislike. Recommendation datasets require careful label definition because conflating these cases with true negative preference biases the model's learned relationships between customers and actions. Anyone debugging biased recommendation labels can find grounded architecture patterns like this on daily.dev."}},{"@type":"Question","name":"Why does uplift modeling matter more than response probability in a coupon recommendation system?","acceptedAnswer":{"@type":"Answer","text":"A customer predicted to redeem a coupon may have transacted anyway, meaning the coupon created no incremental value, while another customer with the same predicted probability might only transact because of the coupon. Uplift modeling and causal inference target this difference, answering who should receive an offer because it will actually change their behavior, not just who is likely to respond. Teams weighing uplift modeling against plain classification can compare real-world tradeoffs on daily.dev."}},{"@type":"Question","name":"Why would a production recommendation system use batch inference instead of real-time scoring?","acceptedAnswer":{"@type":"Answer","text":"Batch inference can generate recommendations for millions of customers ahead of time and store them for retrieval when the app opens, which is simpler and more cost-efficient than scoring every request live. Whether to choose batch or real-time depends on latency requirements, data freshness needs, traffic volume, cost, model complexity, and business SLA constraints. Engineers deciding between batch and real-time ML serving can weigh these tradeoffs on daily.dev."}}]}
```

