Maths · Module 1
Functions, Logarithms and Notation
Take each lesson, answer its quiz, then do its practice. After the last lesson come the module quiz, the project and the interview questions.
Lessons
- 1.1Functions and Their GraphsRead a function as a rule from input to output, and recognise the shapes ML keeps using.
- 1.2Exponents and LogarithmsKnow why logs appear everywhere in ML: they turn products into sums, and huge ranges into small ones.
- 1.3Reading ML NotationRead the formulas in ML papers and docs without stalling.
Module material
Take these after the last lesson, in this order. Next on each page leads through them.
- Module quiz15 questions across the whole module. Take it after the last lesson; your first pick on each question is the one that counts.
- PracticeStated as a problem, with no template and no step-by-step instructions. Working out the steps is the point.
- NotebooksOpen them in Google Colab. Each answer is checked as you go: correct, wrong with the expected value, or not answered yet.
- Cheat sheetOne page of the module’s terms, rules and gotchas, with the output each rule produces.
- Interview questions15 questions interviewers ask on this module’s topics, from first principles to the follow-ups. Each comes with a model answer.
Glossary
Every term the module introduces, with the lesson that introduces it.
- function
- a rule that gives exactly one output for each input |
f(x) = 2x + 1,f(2) = 51.1 - input**, **output
- the value a function takes in, and the one it gives back |
2in,5out 1.1 - graph
- every (input, output) pair of a function, drawn as points | the line through
(−2, −3)…(2, 5)1.1 - domain
- the inputs a function accepts | every real number for
2x + 1; positive numbers forlog₂ x1.1 - linear
- a straight-line graph,
ax + b|2x + 11.1 - quadratic
- highest power two; its graph is a parabola |
x²1.1 - exponential
- the input is the exponent,
bˣ; each equal step multiplies the output by the same factor |2ˣdoubles at every step 1.1 - sigmoid
1 / (1 + e⁻ˣ), an S-shaped curve between zero and one |0.5atx = 01.1- logarithm
log₂ xis the power two must be raised to to givex|log₂ 4 = 21.1- rate of change (slope)
- change in output divided by change in input |
2everywhere for2x + 11.1 - stretch
- multiplying the output by
a|2x²1.1 - shift
- adding
k, or replacingxwithx − h|(x − 3)² + 11.1 - vertex
- the lowest or highest point of a parabola |
(3, 1)for2(x − 3)² + 11.1 - linear model
- a prediction that is a straight-line function of its input |
price = 21.425 − 1.228 · age1.1 - residual
- actual value minus predicted value | the middle third's mean,
−1.341.1 - common mistake:
f(x − h) - it moves the graph right by
h; find the input that makes the bracket zero |(x − 3)²moves right 1.1 - common mistake: the line through the middle
- a line through the middle of the points can still be the wrong shape; read the residual pattern |
+ − +by age third 1.1 - base**, **exponent
- in
bⁿ,bis the base andncounts how many times it is multiplied |2³ = 2 × 2 × 21.2 - power
bⁿ|2⁵ = 321.2- root
b^(1/n), the number whosenth power isb|2^½ = 1.41421.2- e
- the base whose exponential has slope one at zero,
2.71828…| slope1.0005at step0.0011.2 - exponential function
exp(x) = eˣ|np.exp(1) = 2.7182818284590451.2- logarithm
- the exponent that gives a number |
log₁₀ 1000 = 31.2 - natural log
ln - the logarithm with base
e|ln 0.5 = −0.69311.2 - inverse function
- a function that undoes another; its graph is the reflection across
y = x|lnundoesexp1.2 - product rule
log(ab) = log a + log b|ln 0.1 = −2.30261.2- scientific notation
- a number times a power of ten; Python writes it
3.6e-06|3.6 × 10⁻⁶1.2 - log scale
- an axis where equal distances are equal ratios |
1, 0.1, 0.01evenly spaced 1.2 - odds
p / (1 − p)|4forp = 0.81.2- log-odds (logit)
ln(p / (1 − p)); the sigmoid turns it back into a probability |1.3863forp = 0.81.2- common mistake:
log(a + b) - the rule is for a product;
log(a + b)is notlog a + log b|ln 0.7 = −0.3567, not−2.30261.2 - common mistake:
np.logof zeros - gives
-infwith a warning, not an error; usenp.log1p|108cells of the email counts 1.2 - index
- a letter that counts through rows (
i) or columns (j) |i = 1, 2, 31.3 - subscript
- a small index written below and to the right |
x₂₁ = 01.3 - superscript
- a small mark above and to the right |
x², orx⁽¹⁾for row 1 1.3 - summation
Σ - add an expression over an index |
Σᵢ₌₁³ i² = 141.3 - product notation
Π - multiply an expression over an index |
Πᵢ₌₁³ i = 61.3 - hat
- a value a model produced, an estimate |
ŷ = (5, −3, 10)1.3 - bar
- a mean |
x̄ = (2, 2),ȳ = 4.66671.3 - star
- the optimal value for an objective |
w* = (2.7667, −0.3333)1.3 - vector
- an ordered list of numbers, written bold |
𝐰 = (3, −1)1.3 - matrix
- a table of numbers, written as a capital |
X, shape(3, 2)1.3 - transpose
- rows and columns swapped |
Xᵀ, shape(2, 3)1.3 ∈- is a member of |
𝐰 ∈ ℝ²1.3 ℝᵈ- lists of
dreal numbers |X ∈ ℝ³ˣ²1.3 - argmin**, **argmax
- the input that gives the lowest, or highest, output |
argmin (w − 3)² + 1 = 31.3 - hyperparameter
- a number chosen before training that controls how a model is fitted |
λ = 0.1, scikit-learn'salpha1.3 - common mistake:
x⁽ⁱ⁾ - a bracketed superscript is row
i, not a power |x⁽¹⁾is row 1 1.3 - common mistake:
ŷandy - not interchangeable; the gap between them is what the model makes small | errors
(−1, 2, 1)1.3 - common mistake:
argmin argminreturns the input,minreturns the value |3against11.3