1 of 9

Lecture 20: ML Model Evaluation

Autumn 2026

1

Sli.do

#cse163

Questions?

Icebreaker

Favorite fun/goofy fact?

CSE 163

CSE 163: ML Model Evaluation

​

​

2 of 9

Announcements

  • Programming Practice 7 due Sunday, November 22 at 11:59pm on Gradescope
  • Project Part 2 (EDA) due Wednesday, November 18 at 11:59pm on Gradescope
  • Homework 5 due Wednesday, November 25 at 11:59pm on Gradescope

2

Questions?

CSE 163: ML Model Evaluation

​

​

3 of 9

One-Hot Encoding

  • One-hot encoding means to transform categorical columns into multiple columns of binary values
    • Mapping categories to numerical numbers can cause unintended consequences because your are implicitly ranking values that are meant to be categorical

3

One-Hot Encoding

CSE 163: ML Model Evaluation

​

​

4 of 9

Overfitting

  • Overfitting is when your model matches the training set too well that it fails to generalize
    • Example: Memorizing answers on a multiple choice test
  • Tall trees models are likely to overfit if you don’t have enough data
    • Can learn very complex boundaries
    • Very few points are at the leaves

4

CSE 163: ML Model Evaluation

​

​

5 of 9

Discussion Question

Why is it bad practice to evaluate your data on your training set?

5

CSE 163: ML Model Evaluation

​

​

6 of 9

Classification ML Pipeline (w/categories)

6

# Separate data

features = data.loc[:, data.columns != 'target']

features = pd.get_dummies(features)

labels = data['target']

# Train/test split

feat_train, feat_test, lab_train, lab_test = \

train_test_split(features, labels, test_size=0.2)

# Create and train model on train set

model = DecisionTreeClassifier()

model.fit(feat_train, lab_train)

# Predict on test data

predictions = model.predict(feat_test)

accuracy_score(lab_test, predictions)

​

CSE 163: ML Model Evaluation

​

​

7 of 9

Model Complexity

  • One hyperparameter to control complexity of decision tree is the max depth of tree

7

CSE 163: ML Model Evaluation

​

​

8 of 9

Visualize the split of data

8

feat_train

lab_train

feat_test

lab_test

fit

Empty model

Trained model

CSE 163: ML Model Evaluation

​

​

9 of 9

Visualize the split of data

9

feat_train

lab_train

feat_test

lab_test

fit

Empty model

Trained model

predictions

accuracy_score

predict

CSE 163: ML Model Evaluation

​

​