Skip to content
🤖What Is Machine Learning, Really?

What Is Machine Learning, Really?

beginner Python 12 minmachine learningsupervised learningfeatures and target
What you'll learn
  • machine learning
  • supervised learning
  • features and target
  • fit and predict
  • out-of-sample prediction
  • linear regression
  • Okun's law

Machine Learning - You Already Know More Than You Think 🤖

Scene: week one of your first analyst job. The chief economist stops at your desk: "Unemployment just jumped this quarter. Give me a GDP growth forecast by lunch." You panic-Google "machine learning", and drown in neural networks and Greek letters. Breathe. The tool you need is one you already met in econometrics class - you just know it under a different name.

The secret nobody tells economics students: the workhorse of machine learning, linear regression, is literally OLS - the same estimator from your econometrics course, same normal equations, same β̂. What changes is not the tool. It is the question you ask of it.

Econometrics vs machine learning - same engine, different exam

EconometricsMachine Learning
GoalExplain: is β significant? What is the causal story?Predict: how accurate on NEW data?
Judged byIn-sample fit: R², t-stats, p-valuesOut-of-sample prediction error
Star of the showThe coefficientsThe predictions
Classic sinOmitted variable biasOverfitting (memorising, not learning)

An econometrician fits on 60 quarters and writes a paper about β̂ and its p-value. An ML practitioner fits on 50 quarters and is graded only on how well the model forecasts the 10 quarters it never saw. Same regression - different scoreboard.

🧠 The mental model: study the past, sit the exam

  • fit() = studying. The model reads the historical data and distils it into what it has learned - for linear regression, just a slope and an intercept. Econometricians call this estimation.
  • predict() = exam day. The model faces a case it has never seen and must answer using only what it learned. Econometricians call this forecasting.

A student who memorises past papers word-for-word aces the mock exam but flunks the real one. In ML that failure is called overfitting - public enemy #1, and it gets its own lesson soon. For now, remember: the grade that counts is the exam on unseen questions.

The Rosetta Stone: ML vocabulary for economists

Learn this mapping once, and every ML tutorial suddenly reads like econometrics:

Econometrics saysML saysIn this lesson
Regressors / independent variablesFeatures (X)change in unemployment
Dependent variableTarget (y)real GDP growth
Estimate the modelTrain / fitmodel.fit(X, y)
ForecastPredictmodel.predict(new_X)
ObservationsSamples12 quarters

Meet scikit-learn - three lines, every model

scikit-learn is Python's standard ML library, and its genius is a uniform ritual that never changes, whatever the model:

Python
model = LinearRegression()   # 1. choose the recipe (nothing learned yet!)
model.fit(X, y)              # 2. study the past   (econometrics: "estimate")
model.predict(new_X)         # 3. sit the exam     (econometrics: "forecast")

One quirk to know: scikit-learn wants X as a 2D structure - rows are samples (quarters), columns are features - even when you have just one feature. That is why the code below builds X as a list of one-element lists.

Your dataset: Okun's law

In 1962, economist Arthur Okun documented one of macro's most reliable regularities: when unemployment rises, GDP growth falls below trend. His original estimate was about 3 points of output per point of unemployment; modern re-estimates (e.g. Ball, Leigh & Loungani) put the coefficient nearer 2 - the value your data follows. Your training set is 12 quarters of stylised data with exactly this pattern, and you will make the machine rediscover Okun's law from the data - which is precisely what "learning" means here.

The learned parameters then have a clean econometric reading:

  • Intercept ≈ trend growth when unemployment is flat (about 3%)
  • Slope ≈ the Okun coefficient (about −2)

Your Task

The starter code loads the 12 quarters and creates a LinearRegression model - but never trains it. Run it as-is: it politely refuses to forecast. Your job is the single most important line in machine learning: the fit call.

Predict before you run: with an intercept near 3 and a slope near −2, what growth should the model forecast for a new quarter where unemployment rises by 0.6pp? Do the mental arithmetic (3 − 2 × 0.6), then run and see how close you were - congratulations, you just sanity-checked an ML model like a professional.

Related terms in the glossary

Further reading

Where to go deeper. Free means a full, legal copy is online.