Machine Learning

3. Machine Learning#

Machine learning is the part of AI that learns patterns from historical data. This chapter walks through the workflow IS professionals need to understand and support: preparing features, training and evaluating a model, and managing that model once it is in use.

  • Training: A model learns from features in historical data, using separate splits to keep the evaluation honest.

  • Model Evaluation: Metrics and the confusion matrix show how often and in what ways a model is wrong.

  • Model Lifecycle: Models are versioned, served, and retrained like other software assets.

Chapter Video

This explainer shows why a model is trained on one part of the data and tested on another, the idea behind honest model evaluation.

Machine Learning Fundamentals: Cross Validation (6:05) by StatQuest with Josh Starmer

Hosted on YouTube; property of its original creator, embedded here for educational reference only.

Learning Objectives

By the end of this chapter, you will be able to:

  1. Prepare features and training, validation, and test splits from a dataset.

  2. Train a classification model with scikit-learn.

  3. Evaluate a model with accuracy, precision, recall, and a confusion matrix.

  4. Recognize overfitting and explain how data splits detect it.

  5. Describe how models are versioned, served, and retrained in production.

Chapter Flow

Glossary

#

Term

Explanation

1

Machine learning

Building models by learning patterns from data instead of writing explicit rules.

2

Feature

An input variable a model uses to make a prediction.

3

Label

The known outcome a supervised model learns to predict.

4

Supervised learning

Learning from examples that include the correct label.

5

Training set

The data a model learns from.

6

Test set

Held-out data used only to estimate how a model performs on new cases.

7

Classification

Predicting which category an input belongs to.

8

Accuracy

The share of predictions that are correct.

9

Precision

Of the cases a model flags as positive, the share that truly are positive.

10

Recall

Of the truly positive cases, the share the model flags.

11

Confusion matrix

A table that counts correct and incorrect predictions by category.

12

Overfitting

Learning the training data so closely that performance on new data drops.

13

Validation set

Development data used to choose features and model settings.

14

TF-IDF

Text features weighted by term frequency and prevalence in the fitted collection.

15

Vocabulary

A mapping from recognized terms to feature positions.

16

Pipeline

Ordered preprocessing and estimator steps fitted and used together.

17

Hyperparameter

A model or training setting selected outside the fitting of learned weights.

18

Stratified split

A split that attempts to preserve class proportions.

19

Data leakage

Information crossing an evaluation boundary in a way that invalidates the intended comparison.

20

Support

The number of actual evaluation examples for a category.

21

Baseline

A simple comparison method for assessing a more complex approach.

22

Model artifact

A stored fitted model and the transformations needed to use it.

23

Model card

A report describing intended uses, evaluation, and limitations.

24

Data drift

A change in the input distribution.

25

Concept drift

A change in the relationship between inputs and labels.

26

Retraining

Fitting a model again with updated data or configuration.

27

F1

The harmonic mean of precision and recall.