@xdev-asia/xdev-knowledge-mcp 1.0.43 → 1.0.44
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/content/pages/xoa-du-lieu-nguoi-dung.md +68 -0
- package/content/series/luyen-thi/luyen-thi-aws-ml-specialty/chapters/01-phan-1-data-engineering/lessons/01-bai-1-data-repositories-ingestion.md +5 -0
- package/content/series/luyen-thi/luyen-thi-aws-ml-specialty/chapters/01-phan-1-data-engineering/lessons/02-bai-2-data-transformation.md +5 -0
- package/content/series/luyen-thi/luyen-thi-aws-ml-specialty/chapters/01-phan-1-data-engineering/lessons/03-bai-3-data-analysis.md +159 -0
- package/content/series/luyen-thi/luyen-thi-aws-ml-specialty/chapters/02-phan-2-modeling/lessons/04-bai-4-sagemaker-built-in-algorithms.md +186 -0
- package/content/series/luyen-thi/luyen-thi-aws-ml-specialty/chapters/02-phan-2-modeling/lessons/05-bai-5-training-hyperparameter-tuning.md +159 -0
- package/content/series/luyen-thi/luyen-thi-aws-ml-specialty/chapters/02-phan-2-modeling/lessons/06-bai-6-model-evaluation.md +169 -0
- package/content/series/luyen-thi/luyen-thi-aws-ml-specialty/chapters/03-phan-3-implementation-operations/lessons/07-bai-7-model-deployment.md +193 -0
- package/content/series/luyen-thi/luyen-thi-aws-ml-specialty/chapters/03-phan-3-implementation-operations/lessons/08-bai-8-model-monitoring-mlops.md +184 -0
- package/content/series/luyen-thi/luyen-thi-aws-ml-specialty/chapters/03-phan-3-implementation-operations/lessons/09-bai-9-security-cost.md +166 -0
- package/content/series/luyen-thi/luyen-thi-aws-ml-specialty/chapters/04-phan-4-on-tap/lessons/10-bai-10-bai-toan-thuong-gap.md +181 -0
- package/content/series/luyen-thi/luyen-thi-aws-ml-specialty/chapters/04-phan-4-on-tap/lessons/11-bai-11-cheat-sheet.md +110 -0
- package/content/series/luyen-thi/luyen-thi-aws-ml-specialty/chapters/04-phan-4-on-tap/lessons/12-bai-12-chien-luoc-thi.md +113 -0
- package/content/series/luyen-thi/luyen-thi-aws-ml-specialty/index.md +1 -1
- package/content/series/luyen-thi/luyen-thi-cka/index.md +217 -0
- package/content/series/luyen-thi/luyen-thi-ckad/index.md +199 -0
- package/content/series/luyen-thi/luyen-thi-gcp-ml-engineer/chapters/01-phan-1-problem-framing/lessons/01-bai-1-framing-ml-problems.md +136 -0
- package/content/series/luyen-thi/luyen-thi-gcp-ml-engineer/chapters/01-phan-1-problem-framing/lessons/02-bai-2-gcp-ai-ml-ecosystem.md +160 -0
- package/content/series/luyen-thi/luyen-thi-gcp-ml-engineer/chapters/02-phan-2-data-engineering/lessons/03-bai-3-data-pipeline.md +174 -0
- package/content/series/luyen-thi/luyen-thi-gcp-ml-engineer/chapters/02-phan-2-data-engineering/lessons/04-bai-4-feature-engineering.md +156 -0
- package/content/series/luyen-thi/luyen-thi-gcp-ml-engineer/chapters/03-phan-3-model-development/lessons/05-bai-5-vertex-ai-training.md +155 -0
- package/content/series/luyen-thi/luyen-thi-gcp-ml-engineer/chapters/03-phan-3-model-development/lessons/06-bai-6-bigquery-ml-tensorflow.md +141 -0
- package/content/series/luyen-thi/luyen-thi-gcp-ml-engineer/chapters/04-phan-4-deployment-mlops/lessons/07-bai-7-model-deployment.md +134 -0
- package/content/series/luyen-thi/luyen-thi-gcp-ml-engineer/chapters/04-phan-4-deployment-mlops/lessons/08-bai-8-vertex-ai-pipelines-mlops.md +149 -0
- package/content/series/luyen-thi/luyen-thi-gcp-ml-engineer/chapters/05-phan-5-responsible-ai/lessons/09-bai-9-responsible-ai.md +128 -0
- package/content/series/luyen-thi/luyen-thi-gcp-ml-engineer/chapters/05-phan-5-responsible-ai/lessons/10-bai-10-cheat-sheet-chien-luoc-thi.md +108 -0
- package/content/series/luyen-thi/luyen-thi-gcp-ml-engineer/index.md +1 -1
- package/content/series/luyen-thi/luyen-thi-kcna/index.md +168 -0
- package/package.json +1 -1
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: 53fa302d-d4b6-483f-af7d-5c9b26bbf21e
|
|
3
|
+
title: 'Bài 6: Model Evaluation & Validation'
|
|
4
|
+
slug: bai-6-model-evaluation
|
|
5
|
+
description: >-
|
|
6
|
+
Metrics: Accuracy, Precision, Recall, F1, AUC-ROC, RMSE, MAE, R².
|
|
7
|
+
Confusion Matrix. Cross-validation strategies.
|
|
8
|
+
SageMaker Clarify cho bias detection & explainability.
|
|
9
|
+
A/B testing với Production Variants.
|
|
10
|
+
duration_minutes: 60
|
|
11
|
+
is_free: true
|
|
12
|
+
video_url: null
|
|
13
|
+
sort_order: 6
|
|
14
|
+
section_title: "Phần 2: Modeling (36%)"
|
|
15
|
+
course:
|
|
16
|
+
id: 019c9619-lt02-7002-c002-lt0200000002
|
|
17
|
+
title: 'Luyện thi AWS Certified Machine Learning - Specialty'
|
|
18
|
+
slug: luyen-thi-aws-ml-specialty
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
<div style="text-align: center; margin: 2rem 0;">
|
|
22
|
+
<img src="/storage/uploads/2026/04/aws-mls-bai6-model-evaluation.png" alt="Model Evaluation Metrics" style="max-width: 800px; width: 100%; border-radius: 12px;" />
|
|
23
|
+
<p><em>Model Evaluation: Classification metrics (AUC-ROC, F1), Regression metrics (RMSE, MAE), và Confusion Matrix</em></p>
|
|
24
|
+
</div>
|
|
25
|
+
|
|
26
|
+
<h2 id="classification-metrics"><strong>1. Classification Metrics</strong></h2>
|
|
27
|
+
|
|
28
|
+
<p>Chọn metric đúng là một trong các kỹ năng quan trọng nhất của ML Engineer. Đề thi MLS-C01 thường cho scenario và hỏi metric phù hợp.</p>
|
|
29
|
+
|
|
30
|
+
<h3 id="confusion-matrix"><strong>1.1. Confusion Matrix</strong></h3>
|
|
31
|
+
|
|
32
|
+
<pre><code class="language-text"> Predicted
|
|
33
|
+
Positive Negative
|
|
34
|
+
Actual Positive │ TP │ FN │ ← Recall = TP / (TP + FN)
|
|
35
|
+
Negative │ FP │ TN │
|
|
36
|
+
|
|
37
|
+
Precision = TP / (TP + FP) ← of all predicted positive, how many are correct?
|
|
38
|
+
Recall = TP / (TP + FN) ← of all actual positive, how many did we catch?
|
|
39
|
+
F1 Score = 2 × (P × R) / (P + R) ← harmonic mean
|
|
40
|
+
Accuracy = (TP + TN) / Total
|
|
41
|
+
</code></pre>
|
|
42
|
+
|
|
43
|
+
<table>
|
|
44
|
+
<thead><tr><th>Metric</th><th>Optimize When</th><th>Real-World Example</th></tr></thead>
|
|
45
|
+
<tbody>
|
|
46
|
+
<tr><td><strong>Precision</strong></td><td>FP cost is high — don't want false alarms</td><td>Spam filter (don't block legitimate email)</td></tr>
|
|
47
|
+
<tr><td><strong>Recall (Sensitivity)</strong></td><td>FN cost is high — don't miss positives</td><td>Cancer detection (find all cancer patients)</td></tr>
|
|
48
|
+
<tr><td><strong>F1 Score</strong></td><td>Balance Precision and Recall, imbalanced data</td><td>Fraud detection</td></tr>
|
|
49
|
+
<tr><td><strong>Accuracy</strong></td><td>Balanced classes only</td><td>Multi-class, balanced datasets</td></tr>
|
|
50
|
+
<tr><td><strong>AUC-ROC</strong></td><td>Ranking quality, threshold-independent</td><td>Credit scoring, ad ranking</td></tr>
|
|
51
|
+
<tr><td><strong>PR-AUC</strong></td><td>Imbalanced, care about minority class</td><td>Fraud, medical diagnoses</td></tr>
|
|
52
|
+
</tbody>
|
|
53
|
+
</table>
|
|
54
|
+
|
|
55
|
+
<blockquote>
|
|
56
|
+
<p><strong>Exam tip:</strong> Kịch bản hay gặp — "Medical diagnosis, missing cancer is worse than false positive" → optimize <strong>Recall</strong>. "Spam detector, blocking good emails is bad" → optimize <strong>Precision</strong>. Imbalanced data → dùng <strong>F1 hoặc AUC-ROC</strong>, không dùng Accuracy.</p>
|
|
57
|
+
</blockquote>
|
|
58
|
+
|
|
59
|
+
<h2 id="regression-metrics"><strong>2. Regression Metrics</strong></h2>
|
|
60
|
+
|
|
61
|
+
<table>
|
|
62
|
+
<thead><tr><th>Metric</th><th>Formula</th><th>Sensitivity to Outliers</th><th>Use Case</th></tr></thead>
|
|
63
|
+
<tbody>
|
|
64
|
+
<tr><td><strong>RMSE</strong></td><td>√(mean(errors²))</td><td>High — penalizes large errors</td><td>When large errors are unacceptable (price prediction)</td></tr>
|
|
65
|
+
<tr><td><strong>MAE</strong></td><td>mean(|errors|)</td><td>Low — equal weight all errors</td><td>Robust for outliers, demand forecasting</td></tr>
|
|
66
|
+
<tr><td><strong>R² (R-squared)</strong></td><td>1 - SS_res/SS_tot</td><td>Medium</td><td>Proportion of variance explained (0–1)</td></tr>
|
|
67
|
+
<tr><td><strong>MAPE</strong></td><td>mean(|error/actual|×100)</td><td>High when actuals near 0</td><td>Percentage error, easy business interpretation</td></tr>
|
|
68
|
+
</tbody>
|
|
69
|
+
</table>
|
|
70
|
+
|
|
71
|
+
<h2 id="cross-validation"><strong>3. Cross-Validation</strong></h2>
|
|
72
|
+
|
|
73
|
+
<table>
|
|
74
|
+
<thead><tr><th>Strategy</th><th>How It Works</th><th>Best For</th></tr></thead>
|
|
75
|
+
<tbody>
|
|
76
|
+
<tr><td><strong>Hold-out Split</strong></td><td>Train/Val/Test split (e.g., 70/15/15)</td><td>Large datasets, fast evaluation</td></tr>
|
|
77
|
+
<tr><td><strong>K-Fold CV</strong></td><td>K subsets, train on K-1, evaluate on 1, repeat K times</td><td>Medium datasets, robust estimate</td></tr>
|
|
78
|
+
<tr><td><strong>Stratified K-Fold</strong></td><td>Same as K-Fold but maintains class proportions each fold</td><td>Imbalanced classification</td></tr>
|
|
79
|
+
<tr><td><strong>Leave-One-Out (LOOCV)</strong></td><td>N-fold (each sample is test once)</td><td>Very small datasets</td></tr>
|
|
80
|
+
<tr><td><strong>Time-Series Split</strong></td><td>Training window grows forward — no future data in training</td><td>Time series data</td></tr>
|
|
81
|
+
</tbody>
|
|
82
|
+
</table>
|
|
83
|
+
|
|
84
|
+
<blockquote>
|
|
85
|
+
<p><strong>Exam tip:</strong> Time series data PHẢI dùng <strong>time-based splits</strong>, không được shuffle rồi dùng K-Fold thông thường — sẽ leak future data vào training.</p>
|
|
86
|
+
</blockquote>
|
|
87
|
+
|
|
88
|
+
<h2 id="clarify"><strong>4. SageMaker Clarify — Bias & Explainability</strong></h2>
|
|
89
|
+
|
|
90
|
+
<p><strong>SageMaker Clarify</strong> phát hiện bias trong data/model và cung cấp model explainability sử dụng <strong>SHAP values</strong>.</p>
|
|
91
|
+
|
|
92
|
+
<table>
|
|
93
|
+
<thead><tr><th>Feature</th><th>What It Does</th><th>Output</th></tr></thead>
|
|
94
|
+
<tbody>
|
|
95
|
+
<tr><td><strong>Pre-training bias detection</strong></td><td>Analyzes raw data before training</td><td>Bias metrics: CI, DPL, KL, JS</td></tr>
|
|
96
|
+
<tr><td><strong>Post-training bias detection</strong></td><td>Evaluates model predictions for bias</td><td>Metrics: DPPL, DI, DCO, RD</td></tr>
|
|
97
|
+
<tr><td><strong>Model Explainability</strong></td><td>SHAP values cho feature importance</td><td>Feature weight contribution per prediction</td></tr>
|
|
98
|
+
</tbody>
|
|
99
|
+
</table>
|
|
100
|
+
|
|
101
|
+
<pre><code class="language-text">SHAP Explainability Example (Loan Approval):
|
|
102
|
+
|
|
103
|
+
Feature SHAP Value Contribution
|
|
104
|
+
─────────────────────────────────────────────
|
|
105
|
+
credit_score +0.42 ↑ approval
|
|
106
|
+
income +0.28 ↑ approval
|
|
107
|
+
debt_ratio -0.35 ↓ approval
|
|
108
|
+
employment_years +0.15 ↑ approval
|
|
109
|
+
age -0.02 minimal impact
|
|
110
|
+
</code></pre>
|
|
111
|
+
|
|
112
|
+
<h2 id="production-variants"><strong>5. A/B Testing với Production Variants</strong></h2>
|
|
113
|
+
|
|
114
|
+
<p>SageMaker Endpoints hỗ trợ <strong>Production Variants</strong> — chạy nhiều models versions cùng lúc với traffic splitting.</p>
|
|
115
|
+
|
|
116
|
+
<pre><code class="language-text">Endpoint with A/B Testing:
|
|
117
|
+
|
|
118
|
+
┌──────────────────────────────┐
|
|
119
|
+
Request ─→ SageMaker Endpoint │
|
|
120
|
+
│ │
|
|
121
|
+
│ Variant A (v1): 80% traffic │──→ Model v1 (current)
|
|
122
|
+
│ Variant B (v2): 20% traffic │──→ Model v2 (candidate)
|
|
123
|
+
└──────────────────────────────┘
|
|
124
|
+
↓
|
|
125
|
+
Compare metrics, shift traffic gradually
|
|
126
|
+
</code></pre>
|
|
127
|
+
|
|
128
|
+
<h2 id="cheat-sheet"><strong>6. Cheat Sheet — Evaluation Metrics</strong></h2>
|
|
129
|
+
|
|
130
|
+
<table>
|
|
131
|
+
<thead><tr><th>Scenario</th><th>Best Metric</th></tr></thead>
|
|
132
|
+
<tbody>
|
|
133
|
+
<tr><td>Medical diagnosis (FN is critical)</td><td>Recall (Sensitivity)</td></tr>
|
|
134
|
+
<tr><td>Spam filter (FP is critical)</td><td>Precision</td></tr>
|
|
135
|
+
<tr><td>Imbalanced fraud detection</td><td>F1 Score, AUC-ROC</td></tr>
|
|
136
|
+
<tr><td>House price prediction (outliers matter)</td><td>RMSE</td></tr>
|
|
137
|
+
<tr><td>Demand forecasting (robust)</td><td>MAE</td></tr>
|
|
138
|
+
<tr><td>Explain individual prediction</td><td>SHAP (via SageMaker Clarify)</td></tr>
|
|
139
|
+
</tbody>
|
|
140
|
+
</table>
|
|
141
|
+
|
|
142
|
+
<h2 id="practice"><strong>7. Practice Questions</strong></h2>
|
|
143
|
+
|
|
144
|
+
<p><strong>Q1:</strong> A hospital wants to build a model to detect early-stage cancer. Missing an actual cancer case is more dangerous than a false positive. Which metric should be OPTIMIZED?</p>
|
|
145
|
+
<ul>
|
|
146
|
+
<li>A) Precision</li>
|
|
147
|
+
<li>B) Recall ✓</li>
|
|
148
|
+
<li>C) Accuracy</li>
|
|
149
|
+
<li>D) RMSE</li>
|
|
150
|
+
</ul>
|
|
151
|
+
<p><em>Explanation: Recall = TP / (TP + FN). Optimizing Recall minimizes False Negatives (missed cancer cases), which is the critical concern here. Precision optimizes against False Positives, Accuracy is misleading for imbalanced medical data, and RMSE is for regression.</em></p>
|
|
152
|
+
|
|
153
|
+
<p><strong>Q2:</strong> A company wants to gradually test a new model version in production while keeping the existing model as fallback. Which SageMaker feature provides this capability?</p>
|
|
154
|
+
<ul>
|
|
155
|
+
<li>A) SageMaker Experiments</li>
|
|
156
|
+
<li>B) SageMaker Pipelines</li>
|
|
157
|
+
<li>C) Production Variants on SageMaker Endpoints ✓</li>
|
|
158
|
+
<li>D) SageMaker Model Monitor</li>
|
|
159
|
+
</ul>
|
|
160
|
+
<p><em>Explanation: SageMaker Endpoints support Production Variants, allowing multiple model versions to run simultaneously with configurable traffic weights. This enables A/B testing and canary deployments without downtime.</em></p>
|
|
161
|
+
|
|
162
|
+
<p><strong>Q3:</strong> A model for predicting house prices has RMSE=50,000 and MAE=20,000. This indicates the presence of what?</p>
|
|
163
|
+
<ul>
|
|
164
|
+
<li>A) High bias</li>
|
|
165
|
+
<li>B) Data leakage</li>
|
|
166
|
+
<li>C) Outliers driving up RMSE ✓</li>
|
|
167
|
+
<li>D) Underfitting</li>
|
|
168
|
+
</ul>
|
|
169
|
+
<p><em>Explanation: When RMSE is significantly higher than MAE, it indicates outliers — since RMSE squares errors, it penalizes large errors much more than MAE. The gap (50k vs 20k) suggests some predictions have very large errors (outliers in target variable).</em></p>
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: 82fb04d8-e74e-4cf3-8b90-cfa274629073
|
|
3
|
+
title: 'Bài 7: Model Deployment — Endpoints & Inference'
|
|
4
|
+
slug: bai-7-model-deployment
|
|
5
|
+
description: >-
|
|
6
|
+
Real-time Endpoints, Batch Transform, Async Inference, Serverless Inference.
|
|
7
|
+
Multi-Model Endpoints, Inference Pipeline.
|
|
8
|
+
Elastic Inference, SageMaker Neo (edge deployment).
|
|
9
|
+
A/B Testing Production Variants.
|
|
10
|
+
duration_minutes: 60
|
|
11
|
+
is_free: true
|
|
12
|
+
video_url: null
|
|
13
|
+
sort_order: 7
|
|
14
|
+
section_title: "Phần 3: ML Implementation & Operations (20%)"
|
|
15
|
+
course:
|
|
16
|
+
id: 019c9619-lt02-7002-c002-lt0200000002
|
|
17
|
+
title: 'Luyện thi AWS Certified Machine Learning - Specialty'
|
|
18
|
+
slug: luyen-thi-aws-ml-specialty
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
<div style="text-align: center; margin: 2rem 0;">
|
|
22
|
+
<img src="/storage/uploads/2026/04/aws-mls-bai7-deployment-options.png" alt="SageMaker Model Deployment Options" style="max-width: 800px; width: 100%; border-radius: 12px;" />
|
|
23
|
+
<p><em>SageMaker Deployment: Real-time Endpoint, Serverless, Async Inference, và Batch Transform</em></p>
|
|
24
|
+
</div>
|
|
25
|
+
|
|
26
|
+
<h2 id="deployment-options"><strong>1. SageMaker Deployment Options</strong></h2>
|
|
27
|
+
|
|
28
|
+
<p>SageMaker cung cấp nhiều inference patterns — mỗi loại phù hợp với workload khác nhau. Phần này thường có 5-8 câu trong đề thi MLS-C01.</p>
|
|
29
|
+
|
|
30
|
+
<blockquote>
|
|
31
|
+
<p><strong>Exam tip:</strong> Key decision factors: latency requirement, volume, cost, payload size. Map these to: Real-time (low latency) → Async (large payload) → Serverless (sporadic) → Batch (no latency need).</p>
|
|
32
|
+
</blockquote>
|
|
33
|
+
|
|
34
|
+
<table>
|
|
35
|
+
<thead><tr><th>Deployment Type</th><th>Latency</th><th>Throughput</th><th>Cost Model</th><th>Best For</th></tr></thead>
|
|
36
|
+
<tbody>
|
|
37
|
+
<tr><td><strong>Real-time Endpoint</strong></td><td>Milliseconds</td><td>High</td><td>Always-on (pay per hour)</td><td>Interactive apps, APIs</td></tr>
|
|
38
|
+
<tr><td><strong>Serverless Inference</strong></td><td>Seconds (cold start)</td><td>Variable</td><td>Pay-per-invocation</td><td>Sporadic, unpredictable traffic</td></tr>
|
|
39
|
+
<tr><td><strong>Async Inference</strong></td><td>Minutes</td><td>High queued</td><td>Pay per processing</td><td>Large payloads, non-urgent</td></tr>
|
|
40
|
+
<tr><td><strong>Batch Transform</strong></td><td>No real-time</td><td>Very high</td><td>Pay per batch job</td><td>Scheduled offline predictions</td></tr>
|
|
41
|
+
</tbody>
|
|
42
|
+
</table>
|
|
43
|
+
|
|
44
|
+
<h2 id="realtime-endpoint"><strong>2. Real-time Inference</strong></h2>
|
|
45
|
+
|
|
46
|
+
<p>Standard deployment — persistent endpoint chạy constantly, responds synchronously.</p>
|
|
47
|
+
|
|
48
|
+
<pre><code class="language-text">Real-time Endpoint Architecture:
|
|
49
|
+
|
|
50
|
+
Client ──→ HTTPS Request
|
|
51
|
+
↓
|
|
52
|
+
SageMaker Endpoint
|
|
53
|
+
┌────────────────┐
|
|
54
|
+
│ Model Server │ ← Instance running 24/7
|
|
55
|
+
│ (TorchServe, │
|
|
56
|
+
│ TensorFlow │
|
|
57
|
+
│ Serving, etc) │
|
|
58
|
+
└────────────────┘
|
|
59
|
+
↓
|
|
60
|
+
Response (ms)
|
|
61
|
+
</code></pre>
|
|
62
|
+
|
|
63
|
+
<h3 id="autoscaling"><strong>2.1. Auto Scaling cho Endpoints</strong></h3>
|
|
64
|
+
|
|
65
|
+
<p>Endpoints có thể scale dựa trên <strong>InvocationsPerInstance</strong> metric qua Application Auto Scaling.</p>
|
|
66
|
+
|
|
67
|
+
<h2 id="serverless"><strong>3. Serverless Inference</strong></h2>
|
|
68
|
+
|
|
69
|
+
<p>Phù hợp khi traffic <strong>không đều, khó dự đoán</strong>. AWS tự động scale, kể cả về 0 khi không có traffic.</p>
|
|
70
|
+
|
|
71
|
+
<table>
|
|
72
|
+
<thead><tr><th>Feature</th><th>Detail</th></tr></thead>
|
|
73
|
+
<tbody>
|
|
74
|
+
<tr><td>Cold start latency</td><td>~1-2 seconds (đầu tiên sau thời gian nhàn rỗi)</td></tr>
|
|
75
|
+
<tr><td>Memory config</td><td>1 GB → 6 GB</td></tr>
|
|
76
|
+
<tr><td>Max payload</td><td>4 MB</td></tr>
|
|
77
|
+
<tr><td>Pricing</td><td>Per inference requests + processing time</td></tr>
|
|
78
|
+
</tbody>
|
|
79
|
+
</table>
|
|
80
|
+
|
|
81
|
+
<h2 id="async"><strong>4. Async Inference</strong></h2>
|
|
82
|
+
|
|
83
|
+
<p>Phù hợp cho <strong>large media files, long processing time</strong>. Request được queued, response lưu vào S3.</p>
|
|
84
|
+
|
|
85
|
+
<pre><code class="language-text">Async Inference Flow:
|
|
86
|
+
|
|
87
|
+
Client ──→ Upload payload to S3 ──→ Invoke Endpoint
|
|
88
|
+
↓
|
|
89
|
+
Queue Request
|
|
90
|
+
↓
|
|
91
|
+
Process when instance available
|
|
92
|
+
↓
|
|
93
|
+
Save output to S3
|
|
94
|
+
↓
|
|
95
|
+
SNS Notification → Client
|
|
96
|
+
</code></pre>
|
|
97
|
+
|
|
98
|
+
<table>
|
|
99
|
+
<thead><tr><th>Feature</th><th>Detail</th></tr></thead>
|
|
100
|
+
<tbody>
|
|
101
|
+
<tr><td>Max payload</td><td>1 GB (vs 6 MB for real-time)</td></tr>
|
|
102
|
+
<tr><td>Auto-scale to 0</td><td>Yes — scales down when queue empty</td></tr>
|
|
103
|
+
<tr><td>Response</td><td>S3 output path + SNS notification</td></tr>
|
|
104
|
+
</tbody>
|
|
105
|
+
</table>
|
|
106
|
+
|
|
107
|
+
<h2 id="batch-transform"><strong>5. Batch Transform</strong></h2>
|
|
108
|
+
|
|
109
|
+
<p>Chạy predictions trên <strong>toàn bộ dataset</strong> theo lịch. Không có endpoint — chỉ chạy khi cần.</p>
|
|
110
|
+
|
|
111
|
+
<pre><code class="language-text">Batch Transform:
|
|
112
|
+
|
|
113
|
+
Input S3 ──→ Batch Transform Job ──→ Output S3
|
|
114
|
+
(CSV/ (ephemeral compute) (CSV/JSON
|
|
115
|
+
JSON/ predictions)
|
|
116
|
+
Parquet) ↑
|
|
117
|
+
No persistent endpoint
|
|
118
|
+
Pay only when running
|
|
119
|
+
</code></pre>
|
|
120
|
+
|
|
121
|
+
<h2 id="multi-model"><strong>6. Multi-Model Endpoints (MME)</strong></h2>
|
|
122
|
+
|
|
123
|
+
<p><strong>MME</strong> cho phép host <strong>nhiều models</strong> trên một endpoint, giảm chi phí inference infrastructure.</p>
|
|
124
|
+
|
|
125
|
+
<table>
|
|
126
|
+
<thead><tr><th>Feature</th><th>Detail</th></tr></thead>
|
|
127
|
+
<tbody>
|
|
128
|
+
<tr><td>Cost saving</td><td>Một endpoint phục vụ hàng ngàn models</td></tr>
|
|
129
|
+
<tr><td>Dynamic loading</td><td>Models loaded into memory on-demand, cached</td></tr>
|
|
130
|
+
<tr><td>Use case</td><td>SaaS multi-tenant với model per customer</td></tr>
|
|
131
|
+
</tbody>
|
|
132
|
+
</table>
|
|
133
|
+
|
|
134
|
+
<h2 id="neo"><strong>7. SageMaker Neo — Edge Deployment</strong></h2>
|
|
135
|
+
|
|
136
|
+
<p><strong>SageMaker Neo</strong> compiles models và optimize cho specific hardware (edge devices, mobile).</p>
|
|
137
|
+
|
|
138
|
+
<pre><code class="language-text">Neo Workflow:
|
|
139
|
+
|
|
140
|
+
Trained Model (S3)
|
|
141
|
+
↓
|
|
142
|
+
Neo Compiler
|
|
143
|
+
(optimizes for target hardware)
|
|
144
|
+
↓
|
|
145
|
+
Optimized Model
|
|
146
|
+
↓
|
|
147
|
+
├── Deploy to IoT Greengrass (edge)
|
|
148
|
+
├── Deploy to ARM devices
|
|
149
|
+
└── Deploy to mobile (Android/iOS)
|
|
150
|
+
</code></pre>
|
|
151
|
+
|
|
152
|
+
<h2 id="cheat-sheet"><strong>8. Cheat Sheet — Deployment Decision</strong></h2>
|
|
153
|
+
|
|
154
|
+
<table>
|
|
155
|
+
<thead><tr><th>Scenario</th><th>Deployment Type</th></tr></thead>
|
|
156
|
+
<tbody>
|
|
157
|
+
<tr><td>Mobile app, real-time response (<100ms)</td><td>Real-time Endpoint</td></tr>
|
|
158
|
+
<tr><td>Traffic is sporadic (few req/hour)</td><td>Serverless Inference</td></tr>
|
|
159
|
+
<tr><td>Video/audio processing (large files)</td><td>Async Inference</td></tr>
|
|
160
|
+
<tr><td>Nightly predictions on full dataset</td><td>Batch Transform</td></tr>
|
|
161
|
+
<tr><td>Thousands of customer-specific models</td><td>Multi-Model Endpoints</td></tr>
|
|
162
|
+
<tr><td>IoT edge device deployment</td><td>SageMaker Neo + Greengrass</td></tr>
|
|
163
|
+
</tbody>
|
|
164
|
+
</table>
|
|
165
|
+
|
|
166
|
+
<h2 id="practice"><strong>9. Practice Questions</strong></h2>
|
|
167
|
+
|
|
168
|
+
<p><strong>Q1:</strong> A company runs an e-commerce chatbot that requires sub-100ms response times during peak shopping hours. Which SageMaker inference type should they use?</p>
|
|
169
|
+
<ul>
|
|
170
|
+
<li>A) Batch Transform</li>
|
|
171
|
+
<li>B) Async Inference</li>
|
|
172
|
+
<li>C) Serverless Inference</li>
|
|
173
|
+
<li>D) Real-time Endpoint ✓</li>
|
|
174
|
+
</ul>
|
|
175
|
+
<p><em>Explanation: Real-time Endpoints provide persistent, always-on inference with millisecond latency. Serverless has cold start delays, Async is asynchronous (not sub-100ms), and Batch Transform is for scheduled offline processing.</em></p>
|
|
176
|
+
|
|
177
|
+
<p><strong>Q2:</strong> A media company wants to run ML classification on 1 GB video files. Processing time is not urgent. Which SageMaker inference option is MOST appropriate?</p>
|
|
178
|
+
<ul>
|
|
179
|
+
<li>A) Real-time Endpoints</li>
|
|
180
|
+
<li>B) Serverless Inference</li>
|
|
181
|
+
<li>C) Async Inference ✓</li>
|
|
182
|
+
<li>D) Batch Transform</li>
|
|
183
|
+
</ul>
|
|
184
|
+
<p><em>Explanation: Async Inference supports payloads up to 1 GB and queues requests for processing, making it ideal for large media files. Real-time is limited to 6 MB payload, Serverless to 4 MB, and Batch Transform is for scheduled bulk predictions without real-time queue.</em></p>
|
|
185
|
+
|
|
186
|
+
<p><strong>Q3:</strong> A SaaS company provides individual ML models for each of their 10,000 enterprise customers. Hosting each on a separate endpoint is too expensive. What is the BEST solution?</p>
|
|
187
|
+
<ul>
|
|
188
|
+
<li>A) Merge all models into one large model</li>
|
|
189
|
+
<li>B) Use SageMaker Multi-Model Endpoints ✓</li>
|
|
190
|
+
<li>C) Deploy all models on a single Batch Transform job</li>
|
|
191
|
+
<li>D) Use Serverless Inference for each model</li>
|
|
192
|
+
</ul>
|
|
193
|
+
<p><em>Explanation: Multi-Model Endpoints (MME) host multiple models on a single endpoint, dynamically loading them into memory on-demand. This is exactly designed for multi-tenant scenarios where each customer has their own model, reducing infrastructure costs by orders of magnitude.</em></p>
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: 5ffdff76-3b56-4c4f-9e66-f0aa1c6642d1
|
|
3
|
+
title: 'Bài 8: Model Monitoring & MLOps'
|
|
4
|
+
slug: bai-8-model-monitoring-mlops
|
|
5
|
+
description: >-
|
|
6
|
+
SageMaker Model Monitor: Data Quality, Model Quality, Bias Drift, Feature Attribution Drift.
|
|
7
|
+
SageMaker Pipelines cho CI/CD ML. Model Registry, Experiments.
|
|
8
|
+
Ground Truth cho data labeling. Autopilot cho AutoML.
|
|
9
|
+
duration_minutes: 60
|
|
10
|
+
is_free: true
|
|
11
|
+
video_url: null
|
|
12
|
+
sort_order: 8
|
|
13
|
+
section_title: "Phần 3: ML Implementation & Operations (20%)"
|
|
14
|
+
course:
|
|
15
|
+
id: 019c9619-lt02-7002-c002-lt0200000002
|
|
16
|
+
title: 'Luyện thi AWS Certified Machine Learning - Specialty'
|
|
17
|
+
slug: luyen-thi-aws-ml-specialty
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
<div style="text-align: center; margin: 2rem 0;">
|
|
21
|
+
<img src="/storage/uploads/2026/04/aws-mls-bai8-mlops-pipeline.png" alt="SageMaker MLOps Pipeline" style="max-width: 800px; width: 100%; border-radius: 12px;" />
|
|
22
|
+
<p><em>SageMaker MLOps: Model Monitor, SageMaker Pipelines, và CI/CD cho ML workflows</em></p>
|
|
23
|
+
</div>
|
|
24
|
+
|
|
25
|
+
<h2 id="model-monitor"><strong>1. SageMaker Model Monitor</strong></h2>
|
|
26
|
+
|
|
27
|
+
<p><strong>SageMaker Model Monitor</strong> tự động monitor deployed models để phát hiện quality issues trong production. Đây là một trong các topics quan trọng nhất cho MLOps.</p>
|
|
28
|
+
|
|
29
|
+
<table>
|
|
30
|
+
<thead><tr><th>Monitor Type</th><th>What It Detects</th><th>Baseline From</th></tr></thead>
|
|
31
|
+
<tbody>
|
|
32
|
+
<tr><td><strong>Data Quality Monitor</strong></td><td>Statistical drift trong input features (mean, std, completeness)</td><td>Training data statistics</td></tr>
|
|
33
|
+
<tr><td><strong>Model Quality Monitor</strong></td><td>Model performance degradation (accuracy, F1 drop)</td><td>Ground truth labels</td></tr>
|
|
34
|
+
<tr><td><strong>Bias Drift Monitor</strong></td><td>Fairness metric shifts in predictions</td><td>Clarify baseline</td></tr>
|
|
35
|
+
<tr><td><strong>Feature Attribution Drift</strong></td><td>SHAP value changes — features changing importance</td><td>Clarify baseline</td></tr>
|
|
36
|
+
</tbody>
|
|
37
|
+
</table>
|
|
38
|
+
|
|
39
|
+
<blockquote>
|
|
40
|
+
<p><strong>Exam tip:</strong> Model Monitor cần <strong>baseline</strong> để compare against. Baseline được tạo từ training data khi deploy. Monitor chạy theo schedule (hourly/daily), so sánh incoming data với baseline và alert nếu drift vượt threshold.</p>
|
|
41
|
+
</blockquote>
|
|
42
|
+
|
|
43
|
+
<h3 id="drift-types"><strong>1.1. Types of Drift</strong></h3>
|
|
44
|
+
|
|
45
|
+
<pre><code class="language-text">Data Drift Types:
|
|
46
|
+
|
|
47
|
+
┌─────────────────────────────────────────────────────┐
|
|
48
|
+
│ Covariate Shift (Input Drift): │
|
|
49
|
+
│ Input distribution P(X) changes │
|
|
50
|
+
│ Example: model trained on summer data, │
|
|
51
|
+
│ production gets winter data │
|
|
52
|
+
│ │
|
|
53
|
+
│ Concept Drift (Label Drift): │
|
|
54
|
+
│ Relationship P(Y|X) changes │
|
|
55
|
+
│ Example: fraud patterns evolve over time │
|
|
56
|
+
│ │
|
|
57
|
+
│ Prior Probability Shift: │
|
|
58
|
+
│ P(Y) class distribution changes │
|
|
59
|
+
│ Example: seasonal products change target balance │
|
|
60
|
+
└─────────────────────────────────────────────────────┘
|
|
61
|
+
</code></pre>
|
|
62
|
+
|
|
63
|
+
<h2 id="pipelines"><strong>2. SageMaker Pipelines — MLOps CI/CD</strong></h2>
|
|
64
|
+
|
|
65
|
+
<p><strong>SageMaker Pipelines</strong> là MLOps workflow orchestration tool — tạo reproducible, automatable ML pipelines.</p>
|
|
66
|
+
|
|
67
|
+
<pre><code class="language-text">SageMaker Pipeline Example:
|
|
68
|
+
|
|
69
|
+
ProcessingStep ──→ TrainingStep ──→ EvaluationStep ──→ ConditionStep
|
|
70
|
+
↓ ↓ ↓ ↓
|
|
71
|
+
Clean Data Train Model Compute Metrics If accuracy > 0.85
|
|
72
|
+
Feature Eng Save Artifact to S3 ↓ ↓
|
|
73
|
+
Register Fail Pipeline
|
|
74
|
+
Model
|
|
75
|
+
</code></pre>
|
|
76
|
+
|
|
77
|
+
<table>
|
|
78
|
+
<thead><tr><th>Step Type</th><th>What It Does</th></tr></thead>
|
|
79
|
+
<tbody>
|
|
80
|
+
<tr><td><strong>ProcessingStep</strong></td><td>Data preprocessing via Processing Jobs</td></tr>
|
|
81
|
+
<tr><td><strong>TrainingStep</strong></td><td>Model training via Training Jobs</td></tr>
|
|
82
|
+
<tr><td><strong>EvaluationStep</strong></td><td>Model evaluation, compute metrics</td></tr>
|
|
83
|
+
<tr><td><strong>ConditionStep</strong></td><td>Branching logic based on metrics</td></tr>
|
|
84
|
+
<tr><td><strong>RegisterModelStep</strong></td><td>Register approved model to Model Registry</td></tr>
|
|
85
|
+
<tr><td><strong>TransformStep</strong></td><td>Batch Transform inference</td></tr>
|
|
86
|
+
</tbody>
|
|
87
|
+
</table>
|
|
88
|
+
|
|
89
|
+
<h2 id="model-registry"><strong>3. SageMaker Model Registry</strong></h2>
|
|
90
|
+
|
|
91
|
+
<p><strong>Model Registry</strong> là centralized catalog để track và govern ML models qua vòng đời của chúng.</p>
|
|
92
|
+
|
|
93
|
+
<table>
|
|
94
|
+
<thead><tr><th>Feature</th><th>Description</th></tr></thead>
|
|
95
|
+
<tbody>
|
|
96
|
+
<tr><td><strong>Model Groups</strong></td><td>Logical grouping các versions của cùng 1 model</td></tr>
|
|
97
|
+
<tr><td><strong>Approval Status</strong></td><td>PendingManualApproval → Approved → Rejected</td></tr>
|
|
98
|
+
<tr><td><strong>Model Lineage</strong></td><td>Track training job, data, artifacts for each version</td></tr>
|
|
99
|
+
<tr><td><strong>Deployment</strong></td><td>Deploy directly from Registry to endpoint</td></tr>
|
|
100
|
+
</tbody>
|
|
101
|
+
</table>
|
|
102
|
+
|
|
103
|
+
<h2 id="ground-truth"><strong>4. SageMaker Ground Truth</strong></h2>
|
|
104
|
+
|
|
105
|
+
<p><strong>Ground Truth</strong> giúp tạo <strong>high-quality labeled training datasets</strong> kết hợp human labelers và automated labeling.</p>
|
|
106
|
+
|
|
107
|
+
<pre><code class="language-text">Ground Truth Workflow:
|
|
108
|
+
|
|
109
|
+
Raw Data (S3) ──→ Labeling Job
|
|
110
|
+
↓
|
|
111
|
+
┌─── Auto Labeling ───┐
|
|
112
|
+
│ (ML model labels │
|
|
113
|
+
│ easy examples) │
|
|
114
|
+
│ │
|
|
115
|
+
└─── Human Labeling ──┘
|
|
116
|
+
(Mechanical Turk
|
|
117
|
+
or private team
|
|
118
|
+
for hard examples)
|
|
119
|
+
↓
|
|
120
|
+
Labeled Dataset (S3)
|
|
121
|
+
</code></pre>
|
|
122
|
+
|
|
123
|
+
<h2 id="autopilot"><strong>5. SageMaker Autopilot — AutoML</strong></h2>
|
|
124
|
+
|
|
125
|
+
<p><strong>Autopilot</strong> automatically trains và tunes ML models — full AutoML với explainability.</p>
|
|
126
|
+
|
|
127
|
+
<table>
|
|
128
|
+
<thead><tr><th>What Autopilot Does</th><th>Detail</th></tr></thead>
|
|
129
|
+
<tbody>
|
|
130
|
+
<tr><td>Auto feature engineering</td><td>Detects data types, handles missing values, encoding</td></tr>
|
|
131
|
+
<tr><td>Algorithm selection</td><td>Tries multiple algorithms (XGBoost, Deep Learning, Linear)</td></tr>
|
|
132
|
+
<tr><td>Hyperparameter tuning</td><td>Bayesian optimization per algorithm</td></tr>
|
|
133
|
+
<tr><td>Explainability</td><td>SageMaker Clarify integration — SHAP values</td></tr>
|
|
134
|
+
<tr><td>Leaderboard</td><td>Ranked models by target metric</td></tr>
|
|
135
|
+
</tbody>
|
|
136
|
+
</table>
|
|
137
|
+
|
|
138
|
+
<blockquote>
|
|
139
|
+
<p><strong>Exam tip:</strong> Autopilot chỉ hỗ trợ <strong>tabular data</strong>. Khi đề hỏi "automate model building for non-technical users" → Autopilot. Khác với SageMaker JumpStart (pre-built models) và Canvas (no-code for business users).</p>
|
|
140
|
+
</blockquote>
|
|
141
|
+
|
|
142
|
+
<h2 id="cheat-sheet"><strong>6. Cheat Sheet — MLOps Services</strong></h2>
|
|
143
|
+
|
|
144
|
+
<table>
|
|
145
|
+
<thead><tr><th>Scenario</th><th>Service</th></tr></thead>
|
|
146
|
+
<tbody>
|
|
147
|
+
<tr><td>Detect data drift in production</td><td>SageMaker Model Monitor (Data Quality)</td></tr>
|
|
148
|
+
<tr><td>Automated ML pipeline CI/CD</td><td>SageMaker Pipelines</td></tr>
|
|
149
|
+
<tr><td>Track và govern model versions</td><td>SageMaker Model Registry</td></tr>
|
|
150
|
+
<tr><td>Label training data at scale</td><td>SageMaker Ground Truth</td></tr>
|
|
151
|
+
<tr><td>AutoML without coding</td><td>SageMaker Autopilot</td></tr>
|
|
152
|
+
<tr><td>Track experiments (metrics, params)</td><td>SageMaker Experiments</td></tr>
|
|
153
|
+
<tr><td>Model performance drop alert</td><td>Model Monitor + CloudWatch Alarms</td></tr>
|
|
154
|
+
</tbody>
|
|
155
|
+
</table>
|
|
156
|
+
|
|
157
|
+
<h2 id="practice"><strong>7. Practice Questions</strong></h2>
|
|
158
|
+
|
|
159
|
+
<p><strong>Q1:</strong> A deployed fraud detection model's accuracy dropped significantly after 3 months. Investigation shows the input feature distributions have changed. What tool should be used to automatically detect this going forward?</p>
|
|
160
|
+
<ul>
|
|
161
|
+
<li>A) SageMaker Clarify</li>
|
|
162
|
+
<li>B) SageMaker Experiments</li>
|
|
163
|
+
<li>C) SageMaker Model Monitor — Data Quality Monitor ✓</li>
|
|
164
|
+
<li>D) SageMaker Ground Truth</li>
|
|
165
|
+
</ul>
|
|
166
|
+
<p><em>Explanation: SageMaker Model Monitor's Data Quality Monitor continuously compares incoming inference data statistics against a baseline from training data. It detects feature drift (changed distributions) and sends CloudWatch alerts when thresholds are exceeded.</em></p>
|
|
167
|
+
|
|
168
|
+
<p><strong>Q2:</strong> A team wants to create a reproducible ML pipeline that automatically retrains and deploys a model when new data arrives, with a human approval step before production deployment. Which service provides this?</p>
|
|
169
|
+
<ul>
|
|
170
|
+
<li>A) SageMaker Autopilot</li>
|
|
171
|
+
<li>B) SageMaker Pipelines + Model Registry ✓</li>
|
|
172
|
+
<li>C) AWS Step Functions only</li>
|
|
173
|
+
<li>D) SageMaker Ground Truth</li>
|
|
174
|
+
</ul>
|
|
175
|
+
<p><em>Explanation: SageMaker Pipelines orchestrates the ML workflow (data prep → train → evaluate → register). Model Registry provides the approval workflow (PendingManualApproval → Approved) with human gate before deployment — the combination is the standard MLOps solution on AWS.</em></p>
|
|
176
|
+
|
|
177
|
+
<p><strong>Q3:</strong> A company needs to label 100,000 images for object detection training. They want to minimize labeling cost by using ML to automatically label easy examples. Which service should they use?</p>
|
|
178
|
+
<ul>
|
|
179
|
+
<li>A) SageMaker Autopilot</li>
|
|
180
|
+
<li>B) Amazon Rekognition Custom Labels</li>
|
|
181
|
+
<li>C) SageMaker Ground Truth with auto-labeling ✓</li>
|
|
182
|
+
<li>D) AWS Glue DataBrew</li>
|
|
183
|
+
</ul>
|
|
184
|
+
<p><em>Explanation: SageMaker Ground Truth uses automated labeling where an ML model labels high-confidence examples automatically, and only uncertain examples are sent to human workers. This can reduce labeling costs by up to 70%.</em></p>
|