Ai4
Building production machine learning pipelines requires coupling MLflow's execution orchestration with Weights & Biases to overcome MLflow's lack of native dataset versioning and ensure complete experiment lineage.
AI-assisted summary of Building Reproducible ML Pipelines with Mlflow & Weights & Biases With Fidelity Investments — original source. Check the original for full context.
Source published:
Detailed notes
## Background Published by Ai4 on YouTube on August 24, 2025, this presentation features Priyanka Asnani, a Senior ML Engineer at Fidelity Investments. The session demonstrates how to construct an end-to-end, reproducible customer churn prediction pipeline using MLflow Projects for orchestration and Weights & Biases for experiment tracking, artifact lineage, and data versioning.
## TL;DR Priyanka Asnani walks through building an end-to-end customer churn prediction pipeline using the Telco benchmark dataset and an XGBoost classifier. The system architecture uses MLflow Projects to modularize and orchestrate discrete data ingestion, cleaning, feature engineering, and model training stages into reproducible components. Weights & Biases manages immutable data and artifact versioning, hyperparameter sweep tracking, and visual lineage mapping across runs. Top-performing candidate models are standardized with explicit MLflow signatures and registered into a central model registry for containerized downstream deployment.
## Atmosphere & style The presentation carries a pragmatic, tutorial-like tone characteristic of an experienced practitioner delivering an enterprise tech talk. Priyanka speaks with structured clarity, methodically stepping through each pipeline component from raw data ingestion to deployment considerations. The pacing is efficient and focused on technical reproducibility, concluding with an open and candid Q&A session where she transparently discusses architectural trade-offs between MLflow and Weights & Biases.
## Key takeaways - [00:04](https://www.youtube.com/watch?v=8vneD7DPtWQ&t=4s) Predicting customer churn enables businesses to take proactive retention measures, which is significantly more cost-effective than acquiring new customers. - [01:34](https://www.youtube.com/watch?v=8vneD7DPtWQ&t=94s) Exploratory analysis on the Telco dataset identifies month-to-month contracts, fiber optic internet, higher monthly charges, and shorter tenures as key churn drivers. - [03:29](https://www.youtube.com/watch?v=8vneD7DPtWQ&t=209s) The end-to-end ML lifecycle cleanly separates training (validation, preprocessing, training, registry) from inference (artifact packaging, Docker containerization, serving). - [04:36](https://www.youtube.com/watch?v=8vneD7DPtWQ&t=276s) MLflow Projects provides reproducible, language-agnostic pipeline orchestration by encapsulating code, pinned dependencies, and execution parameters across environments. - [04:36](https://www.youtube.com/watch?v=8vneD7DPtWQ&t=276s) Orchestrating sub-components via chained mlflow.run calls creates a modular directed acyclic graph (DAG) where outputs serve as inputs for subsequent steps. - [08:10](https://www.youtube.com/watch?v=8vneD7DPtWQ&t=490s) Packaging transformations and the XGBoost classifier into a scikit-learn Pipeline prevents data leakage between training and validation splits. - [08:10](https://www.youtube.com/watch?v=8vneD7DPtWQ&t=490s) Model metric selection must align with business goals: prioritizing recall minimizes missed churners, while prioritizing precision avoids wasted retention incentives. - [10:26](https://www.youtube.com/watch?v=8vneD7DPtWQ&t=626s) Attaching model signatures and input examples via mlflow.sklearn.save_model enforces input/output schema contracts to prevent production serving failures. - [11:34](https://www.youtube.com/watch?v=8vneD7DPtWQ&t=694s) Hydra sweeps automate hyperparameter grid searches across parameters like max_depth and n_estimators for systematic model optimization. - [11:45](https://www.youtube.com/watch?v=8vneD7DPtWQ&t=705s) Weights & Biases provides run comparison dashboards and end-to-end artifact DAG visualizations linking model binaries directly to exact data versions and hyperparameters. - [14:01](https://www.youtube.com/watch?v=8vneD7DPtWQ&t=841s) A centralized Model Registry acts as the single source of truth, organizing release candidates with staging/production tags for deployment and automated rollbacks. - [15:45](https://www.youtube.com/watch?v=8vneD7DPtWQ&t=945s) The hybrid tooling approach pairs MLflow Projects for modular execution with Weights & Biases to overcome MLflow's lack of native dataset versioning. - [15:45](https://www.youtube.com/watch?v=8vneD7DPtWQ&t=945s) Building a baseline reproducible tracking pipeline and experiment dashboard takes approximately two weeks using standardized template code.
## Detailed walkthrough ### [00:04](https://www.youtube.com/watch?v=8vneD7DPtWQ&t=4s) Overview and the Business Case for Churn Prediction
Priyanka introduces the session on building reproducible machine learning training pipelines using MLflow and Weights & Biases (W&B). Her roadmap traces an end-to-end journey starting with the problem statement and dataset exploration, moving through system architecture and pipeline orchestration using MLflow Projects, and culminating in experiment tracking, hyperparameter optimization, and the model registry. The overarching focus centers on delivering reproducible, production-ready ML workflows.
The project frames customer churn as a supervised binary classification problem: predicting whether a given customer is likely to discontinue their subscription based on past behavior, account attributes, and service usage patterns. From a business perspective, retaining existing customers is "significantly more cost effective than acquiring new ones." By identifying high-risk accounts early, organizations can take proactive retention measures such as personalized outreach, targeted discounts, or plan modifications before a customer defects.
[01:34](https://www.youtube.com/watch?v=8vneD7DPtWQ&t=94s) Exploratory Data Analysis of the Telco Dataset
The demonstration uses the Telco Customer Churn dataset, a publicly available benchmark from IBM containing records for over 7,000 customers. The data captures a mix of demographic data, account information, and service usage attributes, including contract type, internet service provider, and monthly charges, with a binary target label indicating whether the customer churned.
```mermaid flowchart LR accTitle: Key Churn Drivers in Telco EDA subgraph Drivers["Identified Churn Risk Factors"] C["Month-to-Month Contract<br/>(Shortest commitment)"] I["Fiber Optic Internet<br/>(Service dissatisfaction/pricing)"] M["Higher Monthly Charges<br/>(Price sensitivity)"] T["Shorter Tenure<br/>(Fragile onboarding period)"] end Drivers --> R["Elevated Churn Risk"] ```
Initial exploratory analysis reveals class imbalance, with significantly more retained customers than churned ones—a factor requiring explicit handling during modeling. Cross-referencing churn against specific features exposes clear behavioral patterns: - **Contract Type:** Month-to-month contracts exhibit the highest churn rate, confirming that customers without long-term commitments leave far more readily. - **Internet Service:** Subscribers with fiber optic service show a noticeably higher churn rate compared to those using DSL or lacking internet service, signaling potential dissatisfaction with pricing or connection reliability. - **Monthly Charges:** Customers paying higher monthly fees demonstrate elevated churn rates, pointing to direct price sensitivity. - **Tenure:** Those who churn typically have shorter tenures, indicating that early customer onboarding and initial experiences are "very critical for their retention."
[03:29](https://www.youtube.com/watch?v=8vneD7DPtWQ&t=209s) High-Level ML Lifecycle: Training and Inference
Priyanka outlines the end-to-end machine learning lifecycle by splitting it into two distinct tracks: the training pipeline and the inference pipeline. The training lifecycle begins with data validation to ensure schema consistency and data quality, moves into preprocessing to transform raw inputs into model-ready features, proceeds through model training and evaluation, and ends by saving and registering vetted models in a model registry.
```mermaid flowchart TD accTitle: High-Level End-to-End ML Architecture subgraph TrainingPipeline["Training Track"] DV["Data Validation & Quality Checks"] --> DP["Data Preprocessing"] DP --> MT["Model Training & Evaluation"] MT --> MR["Model Registry"] end subgraph InferencePipeline["Inference Track"] MR --> PK["Package Artifacts into Docker"] PK --> DP_SERV["Deploy Model Service"] DP_SERV --> UI["Streamlit User Interface"] end ```
The inference pipeline pulls trained model artifacts from the registry, packages them into containerized Docker images, and deploys them as reachable services. While the hands-on project focuses strictly on training and tracking rather than running Docker or Streamlit directly, Priyanka incorporates these downstream stages into the architecture to illustrate how production systems package and expose models for real-time user inputs.
[04:36](https://www.youtube.com/watch?v=8vneD7DPtWQ&t=276s) Orchestrating Pipelines with MLflow Projects
To avoid environmental drift and ad-hoc scripts, the pipeline leverages MLflow Projects. An MLflow Project provides an opinionated specification that encapsulates code, software environments, and execution parameters. Because dependencies can be declared via Conda or Docker, pipelines execute identically across local workstations and cloud compute. Furthermore, the format is CLI-based and language-agnostic, supporting Python alongside R or Julia across diverse engineering teams.
```mermaid flowchart LR accTitle: MLflow Project Pipeline DAG Execution M["main.py (Orchestrator)"] --> S1["get_data Component"] S1 -- "Raw Artifacts" --> S2["basic_cleaning Component"] S2 -- "Clean Artifacts" --> S3["training Component"] S3 -- "Model Artifacts" --> S4["evaluation Component"] ```
Orchestration is handled by a root-level `main.py` script that invokes discrete sub-components through chained `mlflow.run` calls. The execution graph operates as a directed acyclic graph (DAG), where each step consumes the logged output artifacts of the preceding step as its inputs. Structurally, the repository separates concerns cleanly: - **`MLproject` (Root):** Defines the pipeline entry point, execution environment, and configurable workflow parameters. - **Environment Configuration (`conda.yaml`):** Pins exact Python runtime versions and third-party library dependencies. - **`main.py`:** Orchestrates component execution order and manages artifact passing between stages. - **Component Subdirectories:** Isolated modules (`get_data`, `basic_cleaning`, `training`, `evaluation`), each equipped with its own dedicated `MLproject`, environment manifest, and execution script (`run.py`).
[07:26](https://www.youtube.com/watch?v=8vneD7DPtWQ&t=446s) Data Ingestion and Basic Cleaning
The pipeline begins with a modular data acquisition and cleaning step. Raw data is downloaded directly from Weights & Biases artifact storage. The component immediately performs baseline data hygiene: dropping non-predictive identifiers, casting the `TotalCharges` feature to a numeric type, and discarding invalid or corrupted rows.
Once sanitized, the resulting clean dataset is uploaded back to Weights & Biases as a versioned artifact. This step ensures that every downstream training experiment is linked to an immutable, traceable data snapshot. Priyanka notes that while this cleaning takes place locally within the component script, enterprise production architectures would typically handle these aggregations within dedicated feature engineering pipelines integrated with a centralized feature store.
[08:10](https://www.youtube.com/watch?v=8vneD7DPtWQ&t=490s) Feature Engineering and Model Training with XGBoost
Feature engineering groups incoming attributes into three explicit pipelines: binary, categorical, and numerical. For binary columns (such as gender and partner status), an `OrdinalEncoder` is applied. These transformations are consolidated using a scikit-learn `ColumnTransformer`, which is then packaged alongside an XGBoost classifier into a unified `Pipeline` object to prevent data leakage.
```mermaid flowchart LR accTitle: Feature Engineering and Training Pipeline subgraph DataPrep["Preprocessing (ColumnTransformer)"] B["Binary Features"] --> OE["OrdinalEncoder"] C["Categorical Features"] --> OHE["One-Hot / Imputer"] N["Numerical Features"] --> SC["Scaler / Imputer"] end DataPrep --> Pipe["scikit-learn Pipeline"] XGB["XGBoost Classifier"] --> Pipe Pipe --> Fit["Stratified Train / Val Fit"] Fit --> Log["Metric Logging (W&B)"] ```
Target values (`Churn`) are mapped from string values (`Yes`/`No`) to binary integers (`1`/`0`). Data splitting uses stratified sampling to preserve the target class distribution across training and validation sets. Once fitted, the pipeline is evaluated across key classification metrics: - **Metric Prioritization:** Accuracy, Precision, Recall, and F1-score are tracked, with the selection of the primary metric dictated by business goals: - If the organization aims to minimize false negatives (unnoticed churners), **recall** is prioritized. - If avoiding unnecessary retention incentives on non-churners (false positives) is paramount, **precision** takes precedence. - When balancing both errors equally, the **F1-score** acts as the primary evaluation target. - **Logging:** All validation scores are automatically recorded in Weights & Biases for experiment tracking.
[10:26](https://www.youtube.com/watch?v=8vneD7DPtWQ&t=626s) Standardized Model Packaging and Artifact Tracking
To package the trained artifact, the pipeline utilizes `mlflow.sklearn.save_model`. This utility serializes the composite scikit-learn pipeline—encapsulating preprocessing, scaling, encoding, and the trained XGBoost estimator—into a standardized MLflow model directory format.
Critically, the export attaches a model signature defining expected input and output schemas, alongside an input example that serves as a schema test vector for inference requests. This contract prevents downstream failures:
> "This helps us prevent any schema mismatches in production environment."
After saving the model directory locally, the pipeline uploads the entire directory to Weights & Biases as an artifact. This dual-logging strategy links the versioned model binaries directly with run metadata, hyperparameter logs, and evaluation metrics, establishing full lineage.
[11:34](https://www.youtube.com/watch?v=8vneD7DPtWQ&t=694s) Hyperparameter Tuning via Hydra Sweeps
To squeeze maximum performance from the model, the training component integrates Hydra sweeps. This configuration driver initiates an automated grid search over core XGBoost hyperparameters, running systematic sweeps across the parameter space to find the optimal combination.
[11:45](https://www.youtube.com/watch?v=8vneD7DPtWQ&t=705s) Hyperparameter Sweeps and Weights & Biases Experiment Tracking
Running multiple training jobs with varying hyperparameter combinations—such as `max_depth`, `n_estimators`, and `subsample`—generates a large volume of runs that must be logged and systematically compared to identify the top performer. Weights & Biases provides an organized, transparent dashboard for experiment tracking and reproducibility, making workflows production-ready.
```mermaid flowchart LR accTitle: Experiment Tracking and Lineage Architecture accDescr: Diagram showing how training runs log metrics and hyperparameters into a W&B run dashboard and DAG lineage view. subgraph Sweep["Hyperparameter Runs"] R1["Run 1: max_depth, n_estimators"] R2["Run 2: max_depth, n_estimators"] R3["Run N: max_depth, n_estimators"] end subgraph WnB["Weights & Biases Tracking"] Dash["Run Dashboard<br/>• Accuracy, Precision, Recall<br/>• Training Time, Hyperparameters"] DAG["Artifact & DAG View<br/>• Input Datasets<br/>• Trained Model Artifacts<br/>• End-to-End Lineage"] end R1 --> Dash R2 --> Dash R3 --> Dash Dash --> DAG ```
In the W&B run dashboard, each row corresponds to a single model training run. Priyanka logs all core evaluation metrics (accuracy, precision, recall, and training duration) alongside the specific hyperparameter configurations used for each model. Input datasets and trained model binaries are logged and versioned as output artifacts. This artifact management is crucial for debugging: "If I go to my model a month later, which happens very often when we are building these machine learning pipelines, I know precisely which version of the dataset and what hyperparameters and configurations were used at the time of training." Additionally, the W&B Directed Acyclic Graph (DAG) view maps out the complete experiment lineage, showing how raw inputs flow through each component and what artifacts are produced at each stage.
- Key metrics tracked across runs: accuracy, precision, recall, and training execution time. - Key hyperparameters logged: `max_depth`, `n_estimators`, and `subsample`. - Full lineage visibility: Input data versions, code, configs, and output models linked through DAG visualization.
---
[14:01](https://www.youtube.com/watch?v=8vneD7DPtWQ&t=841s) Model Versioning, Model Registry, and Deployment Flow
Once training and evaluation finish, each model is versioned alongside its corresponding code, configuration files, and artifacts to enable historical performance comparison. When a model is selected as the top performer, it is tagged with an environment label (such as `staging` or `prod`) and registered into the Model Registry.
```mermaid flowchart TD accTitle: Model Promotion and Deployment Pipeline accDescr: Flowchart illustrating the promotion of a top model to the registry, containerization with Docker, and deployment. subgraph Selection["Model Selection & Registry"] Best["Top Performing Model"] --> Tag["Tag: 'staging' / 'prod'"] Tag --> Reg["Model Registry<br/>(Single Source of Truth)"] end subgraph Deploy["Downstream Deployment"] Reg --> Pull["Pull Model Artifacts & Test on Prod Data"] Pull --> Dock["Containerize via Docker"] Dock --> Svc["Deploy as Microservice"] end ```
The Model Registry serves as the central single source of truth across the engineering team, holding approved release candidates ready for deployment, continuous monitoring, or rollbacks. In the downstream release flow, engineers pull the registered model artifact, validate it against production data, containerize the serving application with Docker, and deploy it as a live service.
- Tagging scheme: Environment markers like `staging` and `prod` categorize candidate models. - Central registry functions: Acts as a single source of truth for deployment, monitoring, and automated rollbacks. - Containerization: Packaging the verified model artifact with Docker to serve inference requests.
---
[15:45](https://www.youtube.com/watch?v=8vneD7DPtWQ&t=945s) Q&A: Production Monitoring, MLflow vs. W&B, and Setup Timelines
Following the presentation, Priyanka opens the floor to audience questions regarding production validation, tooling trade-offs, and implementation timelines.
```mermaid flowchart LR accTitle: Tooling Comparison MLflow vs Weights & Biases accDescr: Visual mapping of features supported by MLflow versus Weights & Biases. subgraph MLflow["MLflow Core Strengths"] P1["MLflow Projects (Pipeline Packaging)"] P2["Experiment Tracking & Registry"] end subgraph WnB["Weights & Biases Core Strengths"] W1["Native Data Versioning"] W2["Experiment & Metric Tracking"] W3["Lineage Artifact DAGs"] end ```
When asked whether the model is currently active in production and how it has performed, Priyanka clarifies that this was built as a personal project. While the pipeline was deployed, dedicated post-deployment monitoring was not built out for this presentation. She highlights that the critical next operational step would be implementing automated monitoring for data drift and model drift to prevent prediction degradation over time.
An audience member asks why Weights & Biases was selected alongside MLflow when MLflow already includes native experiment tracking and artifact logging. Priyanka explains that MLflow's major limitation is its lack of native dataset versioning: "MLflow doesn't support data versioning, and I wanted one tool that supports everything from data versioning to experiment tracking to having a model registry." While MLflow can log datasets, it does not version them out of the box. Consequently, she opted for a hybrid architecture: MLflow Projects packages and orchestrates the pipeline steps, while Weights & Biases handles data versioning, artifact lineage, and experiment tracking.
Finally, an attendee asks about the time required to adopt and implement this stack from scratch. Priyanka notes that while initial architecture design and automation took experimentation, adopting the approach using template code (which she will make available on GitHub) should take an engineer roughly two weeks to set up a baseline pipeline and experiment tracking dashboard. She emphasizes the necessity of this tracking infrastructure because machine learning is inherently iterative, and teams frequently need to backtrack to earlier high-performing configurations without losing the exact data and parameter lineage that generated them.
## Notable quotes > [00:04](https://www.youtube.com/watch?v=8vneD7DPtWQ&t=4s) significantly more cost effective than acquiring new ones. — Priyanka Asnani
> [01:34](https://www.youtube.com/watch?v=8vneD7DPtWQ&t=94s) very critical for their retention. — Priyanka Asnani
> [10:26](https://www.youtube.com/watch?v=8vneD7DPtWQ&t=626s) This helps us prevent any schema mismatches in production environment. — Priyanka Asnani
> [11:45](https://www.youtube.com/watch?v=8vneD7DPtWQ&t=705s) If I go to my model a month later, which happens very often when we are building these machine learning pipelines, I know precisely which version of the dataset and what hyperparameters and configurations were used at the time of training. — Priyanka Asnani
> [15:45](https://www.youtube.com/watch?v=8vneD7DPtWQ&t=945s) MLflow doesn't support data versioning, and I wanted one tool that supports everything from data versioning to experiment tracking to having a model registry. — Priyanka Asnani
## Mentioned Priyanka Asnani, Fidelity Investments, Ai4, MLflow, Weights & Biases, Hydra, XGBoost, IBM, Telco Customer Churn, scikit-learn, Docker, Streamlit, Conda, Python, R, Julia, GitHub
## Video description Priyanka Asnani, Senior ML Engineer, Fidelity Investments
Abstracts
In this session, Priyanka Asnani will walk you through building an end-to-end, reproducible customer churn prediction pipeline powered by MLflow Projects and Weights & Biases.
We’ll start with the problem statement, dataset overview, and exploratory data analysis before diving into the high-level system design. You’ll learn how to structure ML pipelines using MLflow Projects, chain components effectively, and leverage Hydra sweeps for hyperparameter optimization.
Key components—data cleaning, feature engineering, XGBoost training, experiment tracking, and model registry—will be demonstrated with practical examples. Along the way, we’ll show how to log and track artifacts, metrics, and models using both MLflow and Weights & Biases, and how to register the best model for deployment.
Whether you’re new to MLops or looking to sharpen your pipeline skills, this session offers actionable insights for building scalable, collaborative, and production-ready machine learning workflows.
[Source](https://www.youtube.com/watch?v=8vneD7DPtWQ)