§ 1.1Module I

Machine Learning Basics

1.1 — Machine Learning Basics

Recall first. Imagine you must write a program that detects spam email. What rules would you write, and what happens when spam changes its wording? Write two sentences before reading.

What problem does machine learning solve?

Traditional programming gives a computer explicit rules:

rules + input data → output

Machine learning instead gives a learning procedure examples and lets it infer a model:

examples + correct answers (when available) → learned model
learned model + new input → prediction

The model is not a human-like understanding of the problem. It is a parameterized pattern that is useful for a defined task and performance measure. The central question is not “did the model memorize the training records?” but “does it make useful predictions on new cases?”12

A precise definition

Tom Mitchell’s standard formulation is:

A computer program is said to learn from experience E with respect to some class of tasks T and performance measure P if its performance at tasks in T, as measured by P, improves with experience E.1

This definition prevents a vague answer such as “the computer learns automatically.” Every ML problem should name all three parts:

PartQuestionExample: exam-score prediction
Task (T)What must the system do?Predict a student’s score
Experience (E)What examples does it learn from?Past records of attendance, study hours, and scores
Performance (P)How will success be measured?Mean absolute error (MAE) on unseen students

If the system improves only on the records it already saw, that is not enough. The experience must support performance on the intended task.

The vocabulary of one dataset

Suppose a dataset contains one row per student:

attendancestudy-hoursprevious-scorefinal-score
9287178
6535459

In matrix notation, X usually stores features and y stores targets. A supervised dataset is often written as:

D = {(x₁, y₁), (x₂, y₂), ..., (xₙ, yₙ)}

where xᵢ is the feature vector for example i and yᵢ is its target.3

The ML workflow in miniature

data → representation/features → learning algorithm → model

new features ───────────────────────────────→ prediction

The algorithm is the general procedure (for example, linear regression or a decision-tree learner). The model is the result after that procedure has been fitted to a particular dataset. Two datasets passed through the same algorithm can produce different models.

A practical library such as scikit-learn separates fitting and prediction: an estimator is fitted on X and y, then used to predict targets for new X. For unsupervised estimators, a target y may not be supplied.3

What machine learning is—and is not

ML is useful when:

ML does not automatically provide:

These are issues to diagnose throughout Module I, not promises made by the word “learning.”

Worked example — specify the learning problem

A college wants to predict whether a student will pass a course.

  1. Task: binary classification — predict pass or fail.
  2. Experience: past student records containing permitted features and the final outcome.
  3. Performance: for example, recall for the fail class if missing an at-risk student is costly.
  4. Input: attendance and early-assessment features available before the prediction is made.
  5. Output: a predicted class or a probability of passing.

Notice the last point: a feature such as the final examination score would make the task look accurate but would be unavailable at prediction time. It would also leak the answer into the inputs.

Exercise

For each scenario, name the likely task, one feature, the target (if any), and one sensible performance measure.

  1. Predict tomorrow’s electricity demand from weather and calendar data.
  2. Group news articles by topic when no topic labels are provided.
  3. Decide whether a transaction is fraudulent.
Answers
  1. Regression; feature: temperature; target: demand in kWh; measure: MAE or MSE. 2. Unsupervised clustering; features: article representation; no supplied target; measure: depends on the clustering objective and downstream usefulness. 3. Classification; features: transaction amount and time; target: fraud/not fraud; measure: a metric chosen for the cost of false positives and false negatives, not automatically accuracy.

Exam lens

Definition: Machine learning is the study of algorithms that improve performance on a task through experience, where the task, experience, and performance measure are made explicit.

Do not confuse:

Long-answer skeleton: define ML using T, E, and P; describe X and y; show training and prediction; then state why unseen-data performance matters.

Rapid revision

Sources

Footnotes

  1. Mitchell, T. M. (1997). Machine Learning. McGraw-Hill — task/experience/performance definition. 2

  2. Alpaydın, E. (2020). Introduction to Machine Learning, 4th Ed. MIT Press — learning as improvement from data and the role of models.

  3. scikit-learn, “Getting Started.” https://scikit-learn.org/stable/getting_started.html — samples, features, targets, fitting, prediction, and estimator workflow. 2