CertNote/ Commute Study Notes
Roadmap
KOEN
CLF-C02 · FoundationalCloud Practitioner - Foundational
DVA-C02 · AssociateDeveloper - Associate
SAA-C03 · AssociateSolutions Architect - Associate
SOA-C02 · AssociateCloudOps Engineer - Associate
SAP-C02 · ProfessionalSolutions Architect - Professional
DOP-C02 · ProfessionalDevOps Engineer - Professional
Linux Master 2 · 2급KAIT Linux Master - Level 2
SCS-C03 · SpecialtySecurity - Specialty
Linux Master 1 · 1급KAIT Linux Master - Level 1
MLA-C01 · AssociateMachine Learning Engineer - Associate
  • Week 1
    • 1.The ML Lifecycle and the Role of the ML Engineer
    • 2.ML Problem Types and Evaluation Metric Basics
    • 3.AWS ML Stack at a Glance
    • 4.SageMaker Overview: Studio, Training/Inference, Built-in Algorithms
    • 5.Week 1 Comprehensive Review — ML Fundamentals & AWS Stack
  • Week 2
  • Week 3
  • Week 4
  • Week 5
  • Week 6
  • Week 7
  • Week 8
  • Week 9
  • Week 10
AIF-C01 · FoundationalAI Practitioner - Foundational
DEA-C01 · AssociateData Engineer - Associate
MLS-C01 · SpecialtyMachine Learning - Specialty
SQLD · 개발자SQL Developer (SQLD)

© CertNote · 주간랩스

  • About
  • Changelog
  • Contact
  • Terms
  • Privacy
← MLA-C01/Week 1/Day 2

Based on the MLA-C01 exam guide·Report an error

MLA-C01· AssociateWeek 1 · Day 2~30 min read

Day 2 - ML Problem Types and Evaluation Metric Basics

📌 Key Takeaways

  • ML problems divide by learning style (supervised/unsupervised/reinforcement) and output form (classification/regression/clustering). Identifying which one you have is the starting point for every later choice.
  • Identification rule: labels present means supervised, no labels means unsupervised, learning from rewards means reinforcement.
  • Classification evaluation starts from the confusion matrix (TP/FP/FN/TN). Looking at accuracy as a single number leads to wrong judgments.
  • Accuracy is a trap on imbalanced data: with 0.1% fraud, "all normal" also scores 99.9%. Look at precision, recall, F1, and PR-AUC.
  • The business decides the metric: if a miss is fatal, use recall; if false alarms are costly, use precision.

Learning Style: Are There Labels, or Are There Rewards

When a new project hands you the request "predict whether customers will churn," the first thing an ML engineer should do is not write code but identify what kind of problem this is. If you pick the wrong problem type, every later choice of algorithm and metric goes off track.

ML algorithms fall into three branches based on "what they learn from."

Learning styleLearning signalTypical problemsAWS built-in examples
SupervisedAnswer labelsClassification, regressionXGBoost, Linear Learner
UnsupervisedNone (discovers structure)Clustering, dimensionality reduction, anomaly detectionK-Means, PCA, RCF
ReinforcementRewardSequential decision-makingSageMaker RL

Identification is simple.

  • "Predict customer churn" → past churn outcomes (labels) exist → supervised learning
  • "Group customers into similar clusters" → there are no ground-truth groups → unsupervised (clustering)
  • "A game agent maximizes its score" → trial and error plus rewards → reinforcement learning

Supervised learning is the problem of approximating a function f(X)=Y from input X to output Y. Because labeling is expensive, in practice semi-supervised learning (training with few labels) and self-supervised learning (creating labels from the data itself, the way large language models are trained) have become important. This labeling cost is why Amazon SageMaker Ground Truth exists as a service that automates and outsources labeling.

Output Form: Classification vs Regression vs Clustering

Supervised learning splits again in two depending on what the output is.

CategoryClassificationRegressionClustering
LabelsYesYesNo
OutputDiscrete categoryContinuous numberGroup number
ExamplesChurn/retain, spam/normalTomorrow's sales, house pricesCustomer segments
Typical metricsPrecision/Recall/F1/AUCRMSE, MAE, R²Silhouette, Inertia
XGBoost objectivebinary:logisticreg:squarederror(not applicable)
# Classification: predicting churn with XGBoost (output = probability → discrete label)
estimator = sagemaker.estimator.Estimator(
    image_uri=xgboost_image, role=role,
    instance_count=1, instance_type="ml.m5.xlarge",
    hyperparameters={
        "objective": "binary:logistic",   # binary classification
        "num_round": 100, "max_depth": 5,
    },
)
 
# For regression, you only change the objective
#   "objective": "reg:squarederror"     # continuous value prediction

Even with the same XGBoost, a single objective hyperparameter separates classification from regression. If you misidentify the problem type, things go wrong from here.

Even within classification, you must distinguish whether the output is a "probability" or a "label." binary:logistic returns a probability from 0 to 1, and converting that to a label requires a threshold. The default is 0.5, but if the business can't afford to miss churners, you lower the threshold to classify more people as "churn risk." Threshold adjustment is the heart of the precision-recall trade-off we look at next.

The Starting Point of Classification Evaluation: The Confusion Matrix

To evaluate a classification model, you first need to understand the confusion matrix. It is a 2x2 table crossing predictions with actuals.

                 Actual Positive       Actual Negative
Predicted Pos.   TP (true positive)    FP (false positive)
Predicted Neg.   FN (false negative)   TN (true negative)

              ┌──────────── Precision = TP / (TP + FP)  ← based on the predicted-positive row
              │
   TP  FP ────┘
   FN  TN ────┐
              │
              └──────────── Recall = TP / (TP + FN)  ← based on the actual-positive column

Using the "churn prediction" example, you read it like this.

CellMeaningIn churn prediction
TPCorrectly called a positive a positivePredicted a churner as churn
FPWrongly called a negative a positiveSent a coupon in vain to someone who would stay
FNMissed a positiveMissed a churner, so the customer is lost
TNCorrectly called a negative a negativePredicted a retained customer as retained

Every metric is a combination of these four cells.

The Accuracy Trap and Precision/Recall

Accuracy = (TP+TN) / total. The most intuitive, and the most dangerous. On data where fraud is 0.1%, even a model that guesses "all normal" gets 99.9% accuracy. This is called the accuracy trap on imbalanced data.

So we need two metrics focused on the positive class.

  • Precision = TP / (TP+FP): "Of what it called positive, the share that is truly positive." Use it when you want fewer false alarms (FP).
  • Recall = TP / (TP+FN): "Of the truly positive cases, the share it caught." Use it when you want fewer misses (FN).

The two are in a trade-off. Lowering the threshold predicts more positives, so recall goes up and precision goes down; raising it does the opposite.

Business situationCostlier errorMore important metricReason
Cancer diagnosisFN (missing a patient)RecallMissing one is directly life-threatening
Spam filterFP (flagging normal mail as spam)PrecisionImportant mail must not vanish
Fraud detectionFN (missing fraud)Recall first, balanced with precisionPreventing losses vs inconveniencing legitimate customers
Ad targetingFP (showing ads to uninterested people)PrecisionWasted budget
Equipment failure predictionFN (missing a failure)RecallLine stoppage costs more than inspection

One-line rule for choosing a metric: prioritize the metric that reduces whichever of FN and FP is more expensive for the business.

COMPAS is a recidivism prediction system that US courts used. A 2016 ProPublica report revealed that the rate of false positives (FP), wrongly classifying defendants as "high risk of reoffending," was about 2x higher for Black defendants than for white defendants. Overall accuracy was similar across races, but the distribution of FP/FN differed by group. The lesson: a fairness problem that a single accuracy number misses can only be caught by looking at the confusion matrix level.

F1 and AUC: Summarizing in a Single Number

When you care about both precision and recall, you use the F1 score. It is their harmonic mean.

F1 = 2 * (Precision * Recall) / (Precision + Recall)

The reason for a harmonic mean is that F1 drops sharply if either one is low. With precision 0.9 and recall 0.1, the arithmetic mean is 0.5 but F1 is 0.18. It enforces "being good on only one side isn't enough."

AUC (area under the ROC curve) measures a model's discriminating power regardless of threshold. The ROC curve plots recall (TPR) against the false positive rate (FPR) at every threshold, and the area under it is the AUC.

AUC valueInterpretation
1.0Perfect classification
0.7-0.9A usable level commonly seen in practice
0.5Same as random guessing
< 0.5Effectively predicting backwards (flipping it would actually be better)

Which metric to look at when: this table applies directly to exam identification questions.

SituationMetric to look atReason
Classes are balancedAccuracyIntuitive with little distortion
Extreme imbalancePR-AUC, F1, RecallAccuracy and ROC-AUC look optimistic
Threshold not chosen yetROC-AUCCompares ranking ability independent of threshold
Threshold already chosenPrecision/Recall/F1Performance at actual operating time
Error costs are asymmetricThe metric matching the costly errorMinimize business loss

AUC can also be interpreted as "the probability that, when you randomly pick one positive sample and one negative sample, the model gives the positive a higher score." Because it looks at the model's own ranking ability before a threshold is set, it is useful at the model comparison stage when the threshold isn't decided yet. However, on extremely imbalanced data AUC can come out optimistic, so also look at PR-AUC (the precision-recall curve).

Regression Evaluation Metrics

Regression deals with continuous values, so there is no confusion matrix; it measures "how close the prediction is to the actual."

MetricCalculationOutlier sensitivityUnitWhen to choose
MAEMean of absolute errorsLow (robust)Same as the original valueWhen there are many outliers and you want to reduce their influence
MSEMean of squared errorsHighSquared unitWhen you want to penalize large errors heavily
RMSESquare root of MSEHighSame as the original valueMSE's advantages plus easy interpretation
R²Proportion of variance explainedMediumUnitless (0-1)How much of the variation the model explains
  • For problems where large errors must be especially avoided (inventory forecasting, etc.), use RMSE.
  • If there are many outliers and you need robustness, use MAE.
  • When comparing models across different datasets, the unitless R² is convenient.

⚠️ Pitfall: RMSE and MAE share the property that "lower is better," but you must not compare their magnitudes directly. On the same data RMSE is always at least MAE, and a large gap between them is a signal that a few large errors (outliers) exist.

Confusion Matrix in Numbers

Calculating once sticks longer than memorizing metrics. Suppose a fraud detection model applied to 1,000 transactions gives the following.

                 Actual fraud (30)    Actual normal (970)
Predicted fraud   TP = 18              FP = 42
Predicted normal  FN = 12              TN = 928
MetricCalculationValueHow to read it
Accuracy(18+928)/10000.946Guessing all normal would give 0.97, so it means nothing
Precision18/(18+42)0.300Only 30% of what it flagged as fraud is real
Recall18/(18+12)0.600Caught only 60% of actual fraud, missed 12
F12×0.3×0.6/(0.3+0.6)0.400Dragged down heavily by the low precision
  • Accuracy of 0.946 is even lower than the model that guesses "all normal" (0.970). On imbalanced data, accuracy gives an illusion that can't even clear the baseline.
  • Lowering the threshold increases both TP and FP, moving toward higher Recall and lower Precision.
  • If the loss from one fraud case is much larger than the handling cost of one false alarm, raising Recall is the right direction.

Averaging Methods for Multiclass Classification

With three or more classes, you compute precision and recall per class and then average. The averaging method changes the conclusion.

Averaging methodCalculationWeight on minority classesWhen
MacroSimple average of per-class metricsHigh (all classes equal)When minority classes matter just as much
WeightedAverage weighted by class sample countLowWhen you want overall performance to be representative
MicroPool all TP/FP/FN and calculate onceLowPerformance based on total prediction count

⚠️ Pitfall: In multiclass classification with imbalanced classes, looking only at the weighted average hides minority-class failures behind majority-class performance. If the goal is "catching the minority class well," check the macro average or per-class metrics separately.

What Happens When You Pick the Wrong Metric

Wrong choiceResult
Accuracy on imbalanced dataA model that catches nothing is judged "good"
Precision first for cancer diagnosisFlags only the certain patients as positive and misses many
Recall first for a spam filterBlocks legitimate mail in bulk too
Accuracy for a regression problemThe calculation doesn't even apply
Looking only at ROC-AUC once the threshold is setYou don't know performance at actual operating time

In the next article, we survey the tools that actually solve these problems: AWS's whole ML stack.

📖 Glossary

  • Label: The answer attached to data. The value the model must predict, such as "this customer churned."
  • Confusion matrix: A 2x2 table crossing predictions with actuals. The four cells TP, FP, FN, and TN produce every classification metric.
  • False positive (FP): Said yes when it was no. Sending normal mail to spam.
  • False negative (FN): Said no when it was yes. Letting fraud through as normal.
  • Precision: Of what was called positive, the share that was actually right. A metric that reduces wasted shots.
  • Recall: Of actual positives, the share caught. A metric that reduces misses.
  • F1 score: The harmonic mean of precision and recall. If only one side is good, the score plunges.
  • Threshold: The cut line that turns a predicted probability into positive/negative. Lowering it raises recall, raising it raises precision.
  • ROC-AUC: A 0-1 measure of the "ability to give positives higher scores," independent of threshold. 0.5 is guessing level.
  • PR-AUC: The area under the precision-recall curve. More honest than ROC-AUC on imbalanced data where positives are very rare.

📝 Practice Questions

Click a choice to reveal the answer and explanation.

Question 1

You want to predict customer churn using data that has past churn-outcome labels. What are the learning style and output form of this problem?

Question 2

A model recorded 99.9% accuracy on data where fraudulent transactions are 0.1% of the total. Why can't this accuracy be trusted?

Question 3

For a cancer diagnosis classification model, which evaluation metric should take top priority, and why?

Question 4

A model recorded precision 0.9 and recall 0.1. Why does the F1 score come out at 0.18, far lower than the arithmetic mean of 0.5?

Question 5

Which interpretation is correct for a classification model with a ROC-AUC of 0.5?

PreviousThe ML Lifecycle and the Role of the ML EngineerWeek 1 · Day 1Next AWS ML Stack at a GlanceWeek 1 · Day 3

Official references

  • MLA-C01 official exam page(opens in a new tab)

On this page

  • Key Takeaways
  • Learning Style: Are There Labels, or Are There Rewards
  • Output Form: Classification vs Regression vs Clustering
  • The Starting Point of Classification Evaluation: The Confusion Matrix
  • The Accuracy Trap and Precision/Recall
  • F1 and AUC: Summarizing in a Single Number
  • Regression Evaluation Metrics
  • Confusion Matrix in Numbers
  • Averaging Methods for Multiclass Classification
  • What Happens When You Pick the Wrong Metric
  • Glossary
  • Practice Questions