Learn/Data Science/Chapter 25

Chapter 25 of 30

Keep learning and build your Data Science skills.

83%
Chapter 25

Model Evaluation

Learn how to measure the performance of machine learning models.

Theory

Model evaluation measures how well a model performs on appropriate data. For regression, common metrics include: • MAE • MSE • RMSE • R² For classification: • Accuracy • Precision • Recall • F1 Score • ROC-AUC The chosen metric should match the problem and business objective.

Example

from sklearn.metrics import accuracy_score

actual = [0, 1, 1, 0]
predicted = [0, 1, 0, 0]

score = accuracy_score(
    actual,
    predicted
)

print(score)

Output

The classification accuracy is calculated.

Practice

Evaluate a classification model using accuracy, precision, recall, and F1 score.

Interview Questions

1

Why is model evaluation important?

2

What is accuracy?

3

What is precision?

4

What is recall?

Quick Quiz

Which option best describes this chapter?

A.Measuring model performance
B.Creating databases
C.Writing HTML
D.Designing websites