Đại học Kinh tế Quốc dân – National Economics UniversityMICRO4ASIA
🏆 Arena
Sign inSign up
MICRO4ASIAThe six micro-credentials

Courses are delivered on the Limio learning platform. Limio

← Fundamental of Machine Learning

You are viewing a public preview

Sign in to save your progress, do assignments, join discussions and get feedback.

Sign in
Module 3: Model Evaluation and Optimization

End-of-Course Knowledge Check

Print / Save as PDF

End-of-Course Knowledge Check

This quiz has 15 questions, 5 per module, so you can assess how well you have mastered the whole course. The passing score is 70%, you may retake it as many times as you like, and after each attempt you can see the explanations of the answers.

PartContent
Module 1 (5 questions)Standardization, feature encoding, feature types, avoiding data leakage
Module 2 (5 questions)Logistic regression, Gini, SVM, bootstrapping
Module 3 (5 questions)Precision, Recall, F1, accuracy with imbalanced data, RMSE

Calculation questions with numerical answers: round as the question requires. If you get a part wrong, go back to the units in that part and try again.

This is a self-check and does not replace the official final exam of the course.

Study notes

By the end of this lesson you can:

  • Recall the key preprocessing ideas from Module 1: scaling, feature types, encoding and leakage
  • Recall the key ideas of Module 2: Logistic Regression, Gini, SVM and bootstrapping
  • Compute Module 3 metrics quickly: precision, recall, F1 and RMSE
  • Spot the accuracy trap on imbalanced data
  • Plan which units to review after the self-check

Key idea: The self-check covers five ideas from each module; most questions are quick calculations or "which concept is this?", so practise the formulas and the definitions together.

How the check works

The quiz has 15 questions, 5 per module. The passing score is 70%, you may retake it as many times as you like, and after each attempt you can see explanations. Round numerical answers as each question asks. It is a self-check and does not replace the official final exam. If you get a part wrong, go back to that part's units.

Module 1 review: preparing data

  • Min-max normalisation: x_new = (x - min) / (max - min), which maps a column into the range 0 to 1. Example: with min 0 and max 50, the value 20 becomes 20 / 50 = 0.4.
  • Z-score standardisation: z = (x - mean) / standard deviation. Example: with mean 100 and standard deviation 15, the value 130 becomes 30 / 15 = 2.
  • Feature types: numeric (continuous or discrete), nominal categories with no order (city, colour), ordinal categories with a natural order (education level: high school < bachelor < master).
  • One-hot encoding turns a nominal column with k distinct values into k binary columns. Example: a city column with Hanoi, Da Nang, Hue becomes 3 columns.
  • Avoiding leakage: fit the scaler on the training set only, then use transform on the test set.

Module 2 review: algorithms

  • Logistic Regression is for classification: the sigmoid gives a probability, and a threshold (usually 0.5) gives the label.
  • Gini impurity = 1 - sum of squared class proportions. 0 means a pure node; 0.5 is the maximum for two classes. Example: 3 Yes / 1 No gives 1 - (0.75^2 + 0.25^2) = 0.375.
  • SVM chooses the maximum-margin boundary; the support vectors are the points closest to it, and only they determine where it lies.
  • Bootstrapping samples with replacement, so a row can appear several times in one sample; Random Forest trains one tree per bootstrap sample.

Module 3 review: evaluation

  • Precision = TP / (TP + FP); Recall = TP / (TP + FN); F1 = 2PR / (P + R).
  • RMSE = square root of the mean of squared errors, in the same unit as the target.
  • Imbalanced data: always predicting the majority class can give very high accuracy while finding none of the minority class; use per-class metrics instead.

Worked example

A mixed practice set with different numbers from the quiz, checked in Python.

import math

# Module 1: min-max and z-score
print((20 - 0) / (50 - 0), (130 - 100) / 15)

# Module 2: Gini of a node with 3 Yes and 1 No
p = [3 / 4, 1 / 4]
print(1 - sum(q ** 2 for q in p))

# Module 3: precision, recall, F1 with TP=20, FP=5, FN=10
tp, fp, fn = 20, 5, 10
P, R = tp / (tp + fp), tp / (tp + fn)
print(round(P, 2), round(R, 2), round(2 * P * R / (P + R), 2))

# Module 3: RMSE of errors +1, -2, +2
errors = [1, -2, 2]
print(round(math.sqrt(sum(e ** 2 for e in errors) / len(errors)), 2))

Expected output:

0.4 2.0
0.375
0.8 0.67 0.73
1.73

Step by step for the last two lines: P = 20 / 25 = 0.8 and R = 20 / 30 = 0.67, so F1 = 2 x 0.8 x 0.667 / 1.467 = 0.73. For RMSE, squares are 1, 4, 4, the mean is 3, and the square root of 3 is 1.73.

Common mistakes

  • Mixing up min-max and z-score. Min-max uses min and max; z-score uses mean and standard deviation.
  • Calling an ordered category nominal. If the values have a natural order, the feature is ordinal.
  • Forgetting the square root in RMSE. The mean of squared errors is MSE; RMSE takes its square root.
  • Swapping the denominators of precision and recall. Precision uses FP; recall uses FN.

Summary

  • Module 1: min-max and z-score scaling, feature types, one-hot encoding, fit the scaler on train only.
  • Module 2: Logistic Regression classifies, Gini measures impurity, support vectors fix the SVM boundary, bootstrapping samples with replacement.
  • Module 3: precision, recall, F1 and RMSE formulas, and the accuracy trap on imbalanced data.
  • Pass mark 70%, unlimited retakes, explanations after each attempt.
  • Review the units of any part where you lose marks, then retake the check.

Flashcards · End-of-Course Knowledge Check

9 words
WordMeaningExample
  • Min-max normalisation

    Rescales a value as (x - min) / (max - min), mapping the column into the range 0 to 1.

    min 0, max 50: 20 -> 0.4

  • Z-score standardisation

    Rescales a value as (x - mean) / standard deviation.

    mean 100, sd 15: 130 -> 2.0

  • Nominal feature

    A categorical feature whose values have no natural order.

    city: Hanoi, Da Nang, Hue

  • Ordinal feature

    A categorical feature whose values have a natural order.

    education: high school < bachelor < master

  • One-hot encoding

    Replaces a nominal column with k distinct values by k binary columns.

    3 cities -> 3 columns of 0/1.

  • Fit scaler on train only

    Learn scaling statistics from the training set and only transform the test set, to avoid leakage.

    scaler.fit_transform(x_train); scaler.transform(x_test)

  • Gini impurity

    1 minus the sum of squared class proportions; 0 = pure node, 0.5 = most mixed for two classes.

    3 Yes, 1 No -> 0.375

  • RMSE

    The square root of the mean squared error, in the same unit as the target.

    Errors +1, -2, +2 -> RMSE 1.73

  • F1 score

    Harmonic mean of precision and recall: 2PR / (P + R).

    P 0.8, R 0.67 -> F1 0.73