Course materials · Introduction to Machine Learning

Introduction to Machine Learning

English translation

The splitting criterion changes predictions. Use a simple Threshold to examine the differences among inputs, true labels, and decisions.

Before practice

01 What does it mean to predict well?

Description

Separate true labels from decisions to count errors.

02 Which samples change their decisions when the Threshold changes?

Description

Among samples on either side of the Threshold, decisions change for those crossed by the moving boundary.

Practice

Preview practice notebookDownload practice notebook

1. Rules and Data

Starting conditions

x=[12345678]x=\begin{bmatrix}1&2&3&4&5&6&7&8\end{bmatrix}, y=[00001111]y=\begin{bmatrix}0&0&0&0&1&1&1&1\end{bmatrix}. x is a sensor feature, and y contains Labels for two states.

Procedure

  1. Tabulate predictions from the rule x>4 and the true labels.
  2. Change the Threshold to 3,4,5 and record misclassified samples and Accuracy.

Results to retain

Items to record and points to check
Threshold
Number of correct predictions
Accuracy
Misclassified x values

Points to check

  • Did you separate input features, true labels, and predictions into different columns?

2. Data with One Changed Label

Starting conditions

Preserve the original y, change one Label using y2=y.copy(); y2[3]=1, and compare Thresholds 3,4,5 again.

Procedure

  1. Keep x and Thresholds 3,4,53,4,5 unchanged, and create the modified version using y2=y.copy(); y2[3]=1. Recompute the x > threshold predictions for each Threshold.
  2. For both the original and modified labels, calculate the misclassified sample indices, their count, and accuracy. Record one table row per threshold.
  3. Identify the input, prediction, and true label of the changed sample, and explain which Thresholds had their classification correctness affected by that single Label change.

Results to retain

Items to record and points to check
Threshold
Label condition
Misclassified indices and count
Accuracy

Points to check

  • Did you change only the labels while keeping inputs and thresholds unchanged?

3. Checking Other Inputs

Starting conditions

Apply the selected threshold unchanged to x=[0.52.54.56.5]x=\begin{bmatrix}0.5&2.5&4.5&6.5\end{bmatrix}, y=[0011]y=\begin{bmatrix}0&0&1&1\end{bmatrix}.

Procedure

  1. Choose one of the three thresholds above and record your choice first. Apply the same x > threshold rule to the four new inputs.
  2. Record inputs, predictions, provided Labels, and matches in four rows, and calculate Accuracy. Place it beside the Accuracy for the original 8 samples and Labels from Activity 1 using the same Threshold, and explain the difference.

Results to retain

Items to record and points to check
Threshold used
New inputs and true labels
Prediction and match status
Accuracy on baseline and new inputs

Points to check

  • Did you keep the selected Threshold unchanged for new inputs?