02.01 Lesson 1 of 12

48 min

Functions, Graphs & ML Notation

Read the notation that appears in model equations: inputs, outputs, parameters, sums and the basic role of logarithms.

By the end of this lesson

You will be able to

  • Explain a function as a mapping from inputs to outputs.
  • Read indexed and summation notation such as x_i and Σ.
  • Interpret slope and intercept in a straight-line function.
  • Explain why logarithms undo exponentials.

A function is a rule with an input and output

A function takes an input and returns an output. In f(x) = 2x + 3, the name f identifies the rule, x is the input and f(x) is the result. A model is also a function: it maps an example and learned parameters to a prediction. For several features, write f(x₁, x₂, …, xₚ; θ), where θ represents the parameters the model can adjust.

def f(x):
    return 2 * x + 3

print(f(4))  # 11

Read the notation you will meet repeatedly

x_i means the i-th value or example, ŷ_i means its prediction, y_i is its observed target and n is the number of observations. A summation such as Σᵢ₌₁ⁿ (y_i - ŷ_i)² means calculate a squared error for each observation and add the results. In y = wx + b, w is the slope and b is the intercept. A logarithm answers the question: “to what power must this base be raised?” It is useful for interpreting multiplicative scales and probability calculations.

Apply what you learned

Exercise

Translate a model equation

Turn a small linear rule and a sum into ordinary Python operations. The goal is to read the symbols, not to build a model yet.

  1. Write f(x) = 1.5x + 4 as a Python function.
  2. Evaluate it for x = 0, 2 and -3.
  3. Given y = [4, 7, 8] and pred = [5, 6, 10], compute each squared error.
  4. Add the squared errors and divide by the number of observations to calculate the mean squared error.
  5. In a short comment, explain what n, y_i and ŷ_i mean.
Done when

Your code returns the three predictions and calculates the mean squared error as 2.0; the comments correctly identify observed values, predictions and observation count.

Free references

Study resources

2 links
  1. 01
    Functions: FAQ Article

    Read the function-notation definition and the short explanation of inputs and outputs.

  2. 02
    Logs (logarithms), clearly explained Video

    Watch the focused explanation of what a logarithm means and how it reverses exponentiation. Skip unrelated videos in the channel.

Check your understanding

Self-test

2 questions
  1. Question 1

    In ŷᵢ = wxᵢ + b, what does the subscript i identify?

  2. Question 2

    What does Σᵢ₌₁ⁿ aᵢ ask you to do?

Completion check

Move on when

You can translate a short model equation into code and explain the role of the common symbols without guessing.

Quick find

Search Michi

Type to search every stage, section, unit, topic and resource.

Enter opens the first result Esc closes

Reference

Keyboard shortcuts

n
Continue to the first unit not passed
j / k
Next / previous unit
1 2 3
Toggle learned, practised, passed
/
Open search
?
Show this help
Esc
Close open panels