Resume where you left off
Online at https://diogoribeiro7.github.io/analytics-blog-jekyll/2024/04/04/machine-learning-notebook-integration/
Topics
Production-grade machine learning documentation pairs code, metrics, and narrative. This guide walks through a churn prediction notebook and highlights how the DataLog theme embeds notebooks with launch buttons for popular runtimes.
Notebook overview
The project notebook notebooks/churn-segmentation.ipynb contains:
- Feature engineering with pandas and scikit-learn
ColumnTransformer - Model training using
xgboost.XGBClassifier - MLflow logging for parameters, metrics, and artifacts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from xgboost import XGBClassifier
from sklearn.compose import ColumnTransformer
from sklearn.pipeline import Pipeline
from sklearn.preprocessing import OneHotEncoder, StandardScaler
numeric = ["monthly_charges", "tenure", "support_tickets"]
categorical = ["contract", "region"]
preprocess = ColumnTransformer(
[
("num", StandardScaler(), numeric),
("cat", OneHotEncoder(handle_unknown="ignore"), categorical),
]
)
model = Pipeline(
steps=[
("preprocess", preprocess),
(
"classifier",
XGBClassifier(
max_depth=4,
n_estimators=200,
subsample=0.8,
colsample_bytree=0.9,
eval_metric="auc",
),
),
]
)
Launch options
Readers can open the notebook in the environment of their choice, while the theme preserves accessibility labels for screen readers.
Track experiments
1
2
3
4
5
6
7
8
import mlflow
mlflow.set_experiment("churn-segmentation")
with mlflow.start_run(run_name="xgboost-baseline"):
model.fit(train_features, train_labels)
auc = model.score(test_features, test_labels)
mlflow.log_metric("test_auc", auc)
mlflow.xgboost.log_model(model.named_steps["classifier"], "model")
Embed evaluation tables and charts produced by MLflow in the post so stakeholders understand progress:
| Metric | Value |
|---|---|
| Validation AUC | 0.864 |
| Test AUC | 0.851 |
| Drift monitor | Stable |
Checklist before deployment
- Notebook executed from top to bottom without errors
- Model registered with reproducible environment metadata
- Alert thresholds documented for precision/recall trade-offs
DataLog’s notebook integration keeps workflows transparent—link to runnable notebooks, surface experiment logs, and capture decisions alongside the code that produced them.
Your private highlights
Kept in this browser only and never sent anywhere. These are your notes, not comments. With text selected, Alt+Shift+H highlights it and Alt+Shift+N adds a note.
This browser is not letting the site keep data, so saving, progress and highlights are off.
Select a passage of the article to highlight it.
Your reading data
Reproduce this analysis
The code, data and environment behind this article.
- Source code
-
github.com/DiogoRibeiro7/analytics-blog-jekyll
at
v0.8.0 - Data
- /analytics-blog-jekyll/datasets/sample-dataset/ version v1
- Environment
-
requirements.txt
Embed interactive plots, widgets, and demos using <figure>, <iframe>, or <div class="interactive-embed"> containers. Ensure each embed includes descriptive captions for accessibility.
© 2024 Diogo Ribeiro. Text and figures under CC BY 4.0.
How to cite
Use the quick export buttons to save citations for reference managers or copy the formatted text directly.
Diogo Ribeiro (2024). MLOps Walkthrough with Jupyter Notebook Integration. DataLog | Data Science & Research Theme. https://diogoribeiro7.github.io/analytics-blog-jekyll/2024/04/04/machine-learning-notebook-integration/.
BibTeX
RIS
EndNote
Open science & reproducibility badges
These badges highlight the transparency practices applied to this work. Hover or focus on each badge to learn more about the criteria.
- Open Data Dataset and code repository published with permissive license. Public repository, DOI issued, README with reproduction steps.
- Reproducible Workflow Containerized environment and automated tests provided. Continuous integration pipeline with reproducibility checks.
- Transparent Peer Review Peer review reports archived with DOI and linked to article. Open peer review statement and archived reports on Zenodo.