@xdev-asia/xdev-knowledge-mcp 1.0.42 → 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.
Files changed (32) hide show
  1. package/content/pages/xoa-du-lieu-nguoi-dung.md +68 -0
  2. package/content/series/luyen-thi/luyen-thi-aws-ml-specialty/chapters/01-phan-1-data-engineering/lessons/01-bai-1-data-repositories-ingestion.md +198 -0
  3. package/content/series/luyen-thi/luyen-thi-aws-ml-specialty/chapters/01-phan-1-data-engineering/lessons/02-bai-2-data-transformation.md +183 -0
  4. 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
  5. 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
  6. 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
  7. package/content/series/luyen-thi/luyen-thi-aws-ml-specialty/chapters/02-phan-2-modeling/lessons/06-bai-6-model-evaluation.md +169 -0
  8. 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
  9. 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
  10. 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
  11. 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
  12. 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
  13. 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
  14. package/content/series/luyen-thi/luyen-thi-aws-ml-specialty/index.md +1 -1
  15. package/content/series/luyen-thi/luyen-thi-cka/index.md +217 -0
  16. package/content/series/luyen-thi/luyen-thi-ckad/index.md +199 -0
  17. 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
  18. 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
  19. 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
  20. 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
  21. 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
  22. 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
  23. 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
  24. 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
  25. 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
  26. 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
  27. package/content/series/luyen-thi/luyen-thi-gcp-ml-engineer/index.md +1 -1
  28. package/content/series/luyen-thi/luyen-thi-kcna/index.md +168 -0
  29. package/data/quizzes/aws-ai-practitioner.json +362 -0
  30. package/data/quizzes/aws-ml-specialty.json +200 -0
  31. package/data/quizzes/gcp-ml-engineer.json +200 -0
  32. package/package.json +1 -1
@@ -0,0 +1,186 @@
1
+ ---
2
+ id: 8d704042-9cc5-478e-b198-d80ea70c22c5
3
+ title: 'Bài 4: SageMaker Built-in Algorithms'
4
+ slug: bai-4-sagemaker-built-in-algorithms
5
+ description: >-
6
+ XGBoost, Linear Learner, Random Cut Forest, K-Means, KNN.
7
+ BlazingText, Seq2Seq, DeepAR, Object Detection, Semantic Segmentation.
8
+ Khi nào dùng algorithm nào — decision table chi tiết.
9
+ duration_minutes: 90
10
+ is_free: true
11
+ video_url: null
12
+ sort_order: 4
13
+ section_title: "Phần 2: Modeling (36%)"
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-bai4-sagemaker-algorithms.png" alt="SageMaker Built-in Algorithms" style="max-width: 800px; width: 100%; border-radius: 12px;" />
22
+ <p><em>SageMaker Built-in Algorithms: từ XGBoost, Linear Learner đến DeepAR và Image Classification</em></p>
23
+ </div>
24
+
25
+ <h2 id="overview"><strong>1. SageMaker Built-in Algorithms Overview</strong></h2>
26
+
27
+ <p>SageMaker cung cấp 18+ <strong>built-in algorithms</strong> được optimize để chạy distributed trên AWS infrastructure. Đây là topic <strong>cực kỳ quan trọng</strong> trong MLS-C01 — thường chiếm 8-12 câu.</p>
28
+
29
+ <blockquote>
30
+ <p><strong>Exam tip:</strong> Học thuộc bảng "Problem Type → Algorithm". Đề thi luôn cho scenario và hỏi algorithm phù hợp. Key patterns: time series → DeepAR; anomaly → Random Cut Forest; NLP classification → BlazingText; tabular → XGBoost.</p>
31
+ </blockquote>
32
+
33
+ <h2 id="supervised-table"><strong>2. Supervised Learning Algorithms</strong></h2>
34
+
35
+ <table>
36
+ <thead><tr><th>Algorithm</th><th>Problem Type</th><th>Input</th><th>Key Trait</th></tr></thead>
37
+ <tbody>
38
+ <tr><td><strong>XGBoost</strong></td><td>Classification, Regression</td><td>Tabular (CSV/LibSVM)</td><td>Top performer cho tabular data, gradient boosting</td></tr>
39
+ <tr><td><strong>Linear Learner</strong></td><td>Binary/Multiclass classification, Regression</td><td>RecordIO, CSV</td><td>Fast, scalable, regularization built-in</td></tr>
40
+ <tr><td><strong>Factorization Machines</strong></td><td>Binary classification, Regression</td><td>RecordIO-protobuf (sparse)</td><td>Sparse data, recommendation systems, CTR prediction</td></tr>
41
+ <tr><td><strong>KNN (k-Nearest Neighbors)</strong></td><td>Classification, Regression</td><td>RecordIO-protobuf</td><td>Instance-based, no training, lazy learner</td></tr>
42
+ <tr><td><strong>DeepAR</strong></td><td>Time series forecasting</td><td>JSON Lines</td><td>Multiple related time series, probabilistic forecasts</td></tr>
43
+ <tr><td><strong>Object2Vec</strong></td><td>Embeddings</td><td>Paired sequences</td><td>Learn embeddings cho words, products, users</td></tr>
44
+ </tbody>
45
+ </table>
46
+
47
+ <h2 id="nlp-algorithms"><strong>3. NLP Algorithms</strong></h2>
48
+
49
+ <table>
50
+ <thead><tr><th>Algorithm</th><th>Output</th><th>Use Case</th></tr></thead>
51
+ <tbody>
52
+ <tr><td><strong>BlazingText</strong></td><td>Word vectors hoặc text classification</td><td>Sentiment analysis, spam detection, entity classification</td></tr>
53
+ <tr><td><strong>Seq2Seq</strong></td><td>Sequence → Sequence</td><td>Machine translation, summarization, Q&amp;A</td></tr>
54
+ <tr><td><strong>LDA (Latent Dirichlet Allocation)</strong></td><td>Topics per document</td><td>Topic modeling, document categorization</td></tr>
55
+ <tr><td><strong>NTM (Neural Topic Model)</strong></td><td>Latent representations</td><td>Topic modeling với neural networks</td></tr>
56
+ </tbody>
57
+ </table>
58
+
59
+ <blockquote>
60
+ <p><strong>Exam tip:</strong> <strong>BlazingText</strong> có 2 modes: (1) <code>Word2Vec</code> mode — unsupervised, generates word embeddings; (2) <code>Text Classification</code> mode — supervised, like FastText. Phân biệt rõ khi đọc câu hỏi.</p>
61
+ </blockquote>
62
+
63
+ <h2 id="unsupervised-algorithms"><strong>4. Unsupervised Learning Algorithms</strong></h2>
64
+
65
+ <table>
66
+ <thead><tr><th>Algorithm</th><th>Problem Type</th><th>Use Case</th></tr></thead>
67
+ <tbody>
68
+ <tr><td><strong>K-Means</strong></td><td>Clustering</td><td>Customer segmentation, document grouping</td></tr>
69
+ <tr><td><strong>PCA (Principal Component Analysis)</strong></td><td>Dimensionality reduction</td><td>High-dimensional data, feature compression</td></tr>
70
+ <tr><td><strong>Random Cut Forest (RCF)</strong></td><td>Anomaly detection</td><td>Fraud detection, IoT anomaly, time series anomaly</td></tr>
71
+ <tr><td><strong>IP Insights</strong></td><td>Anomaly detection</td><td>Detect unusual IP-entity relationships, security</td></tr>
72
+ </tbody>
73
+ </table>
74
+
75
+ <h2 id="computer-vision"><strong>5. Computer Vision Algorithms</strong></h2>
76
+
77
+ <table>
78
+ <thead><tr><th>Algorithm</th><th>Task</th><th>Output</th></tr></thead>
79
+ <tbody>
80
+ <tr><td><strong>Image Classification</strong></td><td>Multi-class classification</td><td>Class label + confidence</td></tr>
81
+ <tr><td><strong>Object Detection</strong></td><td>Locate + classify objects</td><td>Bounding boxes + labels</td></tr>
82
+ <tr><td><strong>Semantic Segmentation</strong></td><td>Pixel-level classification</td><td>Segmentation mask</td></tr>
83
+ </tbody>
84
+ </table>
85
+
86
+ <h2 id="algorithm-decision"><strong>6. Algorithm Selection Decision Tree</strong></h2>
87
+
88
+ <pre><code class="language-text">What is the problem type?
89
+
90
+ ├── Tabular data, classification/regression?
91
+ │ └── XGBoost (best general choice)
92
+
93
+ ├── Sparse features, recommendation, ad CTR?
94
+ │ └── Factorization Machines
95
+
96
+ ├── Time series forecasting (multiple related series)?
97
+ │ └── DeepAR
98
+
99
+ ├── Anomaly detection on time series / IoT?
100
+ │ └── Random Cut Forest (RCF)
101
+
102
+ ├── Text classification / sentiment?
103
+ │ └── BlazingText (supervised mode)
104
+
105
+ ├── Sequence-to-sequence (translation / summarization)?
106
+ │ └── Seq2Seq
107
+
108
+ ├── Topic modeling?
109
+ │ └── LDA or NTM
110
+
111
+ ├── Clustering?
112
+ │ └── K-Means
113
+
114
+ ├── Dimensionality reduction?
115
+ │ └── PCA
116
+
117
+ └── Image tasks?
118
+ ├── Classification only → Image Classification
119
+ ├── Locate objects → Object Detection
120
+ └── Pixel mask → Semantic Segmentation
121
+ </code></pre>
122
+
123
+ <h2 id="training-modes"><strong>7. Training Input Modes</strong></h2>
124
+
125
+ <table>
126
+ <thead><tr><th>Mode</th><th>How It Works</th><th>Best For</th></tr></thead>
127
+ <tbody>
128
+ <tr><td><strong>File Mode</strong></td><td>Downloads entire dataset to training instance before starting</td><td>Small to medium datasets</td></tr>
129
+ <tr><td><strong>Pipe Mode</strong></td><td>Streams data directly from S3 during training</td><td>Very large datasets — no disk bottleneck</td></tr>
130
+ <tr><td><strong>FastFile Mode</strong></td><td>Access S3 as if local file system (via FUSE)</td><td>Random access patterns</td></tr>
131
+ </tbody>
132
+ </table>
133
+
134
+ <blockquote>
135
+ <p><strong>Exam tip:</strong> Khi đề hỏi "reduce training time for large dataset", đáp án thường là chuyển sang <strong>Pipe Mode</strong> với <strong>RecordIO format</strong>. Pipe Mode không download toàn bộ dataset — stream trực tiếp từ S3.</p>
136
+ </blockquote>
137
+
138
+ <h2 id="cheat-sheet"><strong>8. Cheat Sheet — Quick Reference</strong></h2>
139
+
140
+ <table>
141
+ <thead><tr><th>Keyword in Question</th><th>Algorithm</th></tr></thead>
142
+ <tbody>
143
+ <tr><td>"tabular data", "structured data"</td><td>XGBoost</td></tr>
144
+ <tr><td>"time series", "forecast"</td><td>DeepAR</td></tr>
145
+ <tr><td>"anomaly detection"</td><td>Random Cut Forest</td></tr>
146
+ <tr><td>"recommendation", "sparse features"</td><td>Factorization Machines</td></tr>
147
+ <tr><td>"text classification", "sentiment"</td><td>BlazingText (supervised)</td></tr>
148
+ <tr><td>"word embeddings"</td><td>BlazingText (Word2Vec mode)</td></tr>
149
+ <tr><td>"translation", "summarization"</td><td>Seq2Seq</td></tr>
150
+ <tr><td>"topic modeling"</td><td>LDA or NTM</td></tr>
151
+ <tr><td>"clustering", "segmentation"</td><td>K-Means</td></tr>
152
+ <tr><td>"dimensionality reduction"</td><td>PCA</td></tr>
153
+ <tr><td>"bounding boxes", "object detection"</td><td>Object Detection</td></tr>
154
+ <tr><td>"pixel-level", "segmentation mask"</td><td>Semantic Segmentation</td></tr>
155
+ <tr><td>"IP address anomaly", "fraud login"</td><td>IP Insights</td></tr>
156
+ </tbody>
157
+ </table>
158
+
159
+ <h2 id="practice"><strong>9. Practice Questions</strong></h2>
160
+
161
+ <p><strong>Q1:</strong> A retail company wants to forecast product demand for the next 30 days across 5,000 product categories. Which SageMaker algorithm is BEST suited?</p>
162
+ <ul>
163
+ <li>A) K-Means</li>
164
+ <li>B) Linear Learner</li>
165
+ <li>C) DeepAR ✓</li>
166
+ <li>D) Seq2Seq</li>
167
+ </ul>
168
+ <p><em>Explanation: DeepAR is specifically designed for time series forecasting across multiple related time series. It learns global patterns from all 5,000 series simultaneously, providing probabilistic forecasts. This is exactly the use case it's optimized for.</em></p>
169
+
170
+ <p><strong>Q2:</strong> An IoT system monitors server CPU usage. The team wants to detect unusual spikes automatically. Which SageMaker built-in algorithm should be used?</p>
171
+ <ul>
172
+ <li>A) XGBoost</li>
173
+ <li>B) Random Cut Forest ✓</li>
174
+ <li>C) BlazingText</li>
175
+ <li>D) PCA</li>
176
+ </ul>
177
+ <p><em>Explanation: Random Cut Forest (RCF) is SageMaker's built-in anomaly detection algorithm. It assigns an anomaly score to each data point and works well for time series anomaly detection, such as CPU usage spikes.</em></p>
178
+
179
+ <p><strong>Q3:</strong> A data scientist is training a model on a 500 GB dataset. Training is very slow because downloading data to the training instance takes too long. Which change will MOST improve performance?</p>
180
+ <ul>
181
+ <li>A) Switch from CSV to JSON format</li>
182
+ <li>B) Increase the training instance size</li>
183
+ <li>C) Switch to Pipe Mode with RecordIO-protobuf format ✓</li>
184
+ <li>D) Add more training epochs</li>
185
+ </ul>
186
+ <p><em>Explanation: Pipe Mode streams data directly from S3 during training without downloading it first, eliminating the I/O bottleneck for large datasets. Combined with RecordIO-protobuf format, it dramatically reduces startup time.</em></p>
@@ -0,0 +1,159 @@
1
+ ---
2
+ id: 8a7a5367-e4a4-4796-8aab-68326c1dc574
3
+ title: 'Bài 5: Training & Hyperparameter Tuning'
4
+ slug: bai-5-training-hyperparameter-tuning
5
+ description: >-
6
+ SageMaker Training Jobs: instance types, Pipe Mode vs File Mode.
7
+ Distributed training: data parallelism vs model parallelism.
8
+ Automatic Model Tuning (HPO): Bayesian vs Random vs Grid search.
9
+ Spot Instance Training để giảm chi phí.
10
+ duration_minutes: 60
11
+ is_free: true
12
+ video_url: null
13
+ sort_order: 5
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-bai5-training-hpo.png" alt="SageMaker Training & Hyperparameter Tuning" style="max-width: 800px; width: 100%; border-radius: 12px;" />
23
+ <p><em>SageMaker Training Jobs & Hyperparameter Tuning: distributed training, Spot Instances, và HPO strategies</em></p>
24
+ </div>
25
+
26
+ <h2 id="training-jobs"><strong>1. SageMaker Training Jobs</strong></h2>
27
+
28
+ <p><strong>SageMaker Training Jobs</strong> chạy ML training code trên managed compute infrastructure. Training xảy ra trên ephemeral instances — chỉ tính phí khi chạy.</p>
29
+
30
+ <pre><code class="language-text">Training Job Lifecycle:
31
+
32
+ Submit Job ──→ Provision Instances ──→ Download Data
33
+
34
+ Run Training Code
35
+
36
+ Save Model to S3
37
+
38
+ Terminate Instances
39
+ </code></pre>
40
+
41
+ <h2 id="instance-types"><strong>2. Instance Types cho Training</strong></h2>
42
+
43
+ <table>
44
+ <thead><tr><th>Instance Family</th><th>Hardware</th><th>Best For</th></tr></thead>
45
+ <tbody>
46
+ <tr><td><strong>ml.c5</strong></td><td>CPU optimized</td><td>Tabular ML, XGBoost, sklearn</td></tr>
47
+ <tr><td><strong>ml.m5</strong></td><td>General purpose CPU</td><td>Light training, data processing</td></tr>
48
+ <tr><td><strong>ml.p3</strong></td><td>V100 GPU</td><td>Deep learning training</td></tr>
49
+ <tr><td><strong>ml.p4d</strong></td><td>A100 GPU (8x)</td><td>Large-scale DL, distributed training</td></tr>
50
+ <tr><td><strong>ml.g4dn</strong></td><td>T4 GPU (cost-effective)</td><td>Small-medium DL models</td></tr>
51
+ <tr><td><strong>ml.trn1</strong></td><td>AWS Trainium</td><td>LLM training, cost optimization</td></tr>
52
+ </tbody>
53
+ </table>
54
+
55
+ <h2 id="distributed-training"><strong>3. Distributed Training</strong></h2>
56
+
57
+ <p>Khi model hoặc dataset quá lớn cho một instance, cần <strong>distributed training</strong> trên nhiều instances.</p>
58
+
59
+ <table>
60
+ <thead><tr><th>Strategy</th><th>How It Works</th><th>When to Use</th></tr></thead>
61
+ <tbody>
62
+ <tr><td><strong>Data Parallelism</strong></td><td>Mỗi instance có copy của model, train trên subset của data, sync gradients</td><td>Dataset quá lớn, model vừa vặn trong 1 GPU</td></tr>
63
+ <tr><td><strong>Model Parallelism</strong></td><td>Model split across instances, mỗi instance chứa 1 phần</td><td>Model quá lớn cho 1 GPU (LLMs)</td></tr>
64
+ </tbody>
65
+ </table>
66
+
67
+ <pre><code class="language-text">Data Parallelism:
68
+
69
+ Instance 1 [Full Model] ──→ Train on data shard A ──→ ↓
70
+ Instance 2 [Full Model] ──→ Train on data shard B ──→ ↓ AllReduce
71
+ Instance 3 [Full Model] ──→ Train on data shard C ──→ ↓ (sync gradients)
72
+
73
+ Updated Model Weights
74
+
75
+ Model Parallelism:
76
+
77
+ Instance 1 [Layers 1-4] ──→ forward pass ──→
78
+ Instance 2 [Layers 5-8] ──→ forward pass ──→
79
+ Instance 3 [Layers 9-12] ──→ forward pass ──→ output
80
+ </code></pre>
81
+
82
+ <blockquote>
83
+ <p><strong>Exam tip:</strong> SageMaker cung cấp <strong>SageMaker Distributed</strong> library với 2 modules: (1) <code>smdistributed.dataparallel</code> — optimized AllReduce; (2) <code>smdistributed.modelparallel</code> — auto pipeline parallelism. Khi đề hỏi "large model training" → model parallelism.</p>
84
+ </blockquote>
85
+
86
+ <h2 id="hpo"><strong>4. Automatic Model Tuning (HPO)</strong></h2>
87
+
88
+ <p><strong>Hyperparameter Optimization (HPO)</strong> tự động tìm hyperparameters tốt nhất bằng cách chạy nhiều training jobs với configs khác nhau.</p>
89
+
90
+ <table>
91
+ <thead><tr><th>Strategy</th><th>How It Works</th><th>Tradeoff</th></tr></thead>
92
+ <tbody>
93
+ <tr><td><strong>Random Search</strong></td><td>Randomly sample hyperparameters từ range</td><td>Fast, good baseline</td></tr>
94
+ <tr><td><strong>Grid Search</strong></td><td>Try all combinations</td><td>Exhaustive, expensive, bad for large spaces</td></tr>
95
+ <tr><td><strong>Bayesian Optimization</strong></td><td>Probabilistic model của outcome, suggest best next config</td><td>Efficient, learns from previous trials — SageMaker default</td></tr>
96
+ <tr><td><strong>Hyperband</strong></td><td>Early-stop poorly performing trials</td><td>Resource-efficient, fast</td></tr>
97
+ </tbody>
98
+ </table>
99
+
100
+ <blockquote>
101
+ <p><strong>Exam tip:</strong> SageMaker AMT (Automatic Model Tuning) dùng <strong>Bayesian Optimization</strong> by default. Nó XEM KẾT QUẢ từ các jobs trước để suggest next hyperparameter set — intelligent search, không phải brute force.</p>
102
+ </blockquote>
103
+
104
+ <h2 id="spot-training"><strong>5. Spot Instance Training</strong></h2>
105
+
106
+ <p>SageMaker hỗ trợ dùng <strong>EC2 Spot Instances</strong> cho training jobs, tiết kiệm đến <strong>90% chi phí</strong> so với On-Demand.</p>
107
+
108
+ <table>
109
+ <thead><tr><th>Feature</th><th>Detail</th></tr></thead>
110
+ <tbody>
111
+ <tr><td><strong>MaxWaitTimeInSeconds</strong></td><td>Maximum thời gian đợi spot capacity</td></tr>
112
+ <tr><td><strong>Checkpointing</strong></td><td>Lưu model to S3 periodically — resume sau khi bị interrupt</td></tr>
113
+ <tr><td><strong>use_spot_instances=True</strong></td><td>Parameter trong SageMaker Estimator</td></tr>
114
+ </tbody>
115
+ </table>
116
+
117
+ <blockquote>
118
+ <p><strong>Exam tip:</strong> Khi đề hỏi "reduce training costs", đáp án thường là <strong>Spot Instances với checkpointing</strong>. Checkpointing quan trọng để tránh mất progress khi spot instance bị terminate.</p>
119
+ </blockquote>
120
+
121
+ <h2 id="bias-variance"><strong>6. Bias-Variance Tradeoff</strong></h2>
122
+
123
+ <table>
124
+ <thead><tr><th>Issue</th><th>Symptom</th><th>Cause</th><th>Solution</th></tr></thead>
125
+ <tbody>
126
+ <tr><td><strong>High Bias (Underfitting)</strong></td><td>High train error, high test error</td><td>Model quá đơn giản</td><td>Tăng model complexity, thêm features, giảm regularization</td></tr>
127
+ <tr><td><strong>High Variance (Overfitting)</strong></td><td>Low train error, high test error</td><td>Model quá phức tạp</td><td>Thêm data, dropout, regularization, feature selection</td></tr>
128
+ <tr><td><strong>Balanced</strong></td><td>Low train error, low test error (gần nhau)</td><td>Good fit</td><td>Deploy model</td></tr>
129
+ </tbody>
130
+ </table>
131
+
132
+ <h2 id="practice"><strong>7. Practice Questions</strong></h2>
133
+
134
+ <p><strong>Q1:</strong> A company is training a large deep learning model that doesn't fit on a single GPU instance. Which SageMaker distributed training strategy should they use?</p>
135
+ <ul>
136
+ <li>A) Data parallelism</li>
137
+ <li>B) Model parallelism ✓</li>
138
+ <li>C) Pipeline parallelism only</li>
139
+ <li>D) Increase batch size</li>
140
+ </ul>
141
+ <p><em>Explanation: Model parallelism splits the model itself across multiple GPU instances, allowing training of models too large to fit in a single GPU's memory. Data parallelism keeps a full model copy on each instance, which doesn't help when the model itself is too large.</em></p>
142
+
143
+ <p><strong>Q2:</strong> A team wants to minimize the cost of running 500 hyperparameter tuning jobs. Training can tolerate interruptions. What is the MOST cost-effective approach?</p>
144
+ <ul>
145
+ <li>A) Use larger instances to run jobs faster</li>
146
+ <li>B) Use Spot Instances with checkpointing enabled ✓</li>
147
+ <li>C) Use Grid Search instead of Bayesian Optimization</li>
148
+ <li>D) Reduce the number of epochs</li>
149
+ </ul>
150
+ <p><em>Explanation: Spot Instances can save up to 90% compared to On-Demand pricing. With checkpointing enabled, interrupted jobs save their state to S3 and can resume, making Spot Instances practical for long HPO jobs.</em></p>
151
+
152
+ <p><strong>Q3:</strong> A model achieves 95% accuracy on training data but only 62% on the test set. What problem does this indicate?</p>
153
+ <ul>
154
+ <li>A) Underfitting / High bias</li>
155
+ <li>B) Overfitting / High variance ✓</li>
156
+ <li>C) Data leakage</li>
157
+ <li>D) Class imbalance</li>
158
+ </ul>
159
+ <p><em>Explanation: The large gap between training accuracy (95%) and test accuracy (62%) is a classic sign of overfitting (high variance). The model memorized the training data but fails to generalize. Solutions: more data, regularization (L1/L2, dropout), reduce model complexity.</em></p>
@@ -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>