Tools 1.6Code walkthrough10 parts

Linear Algebra in NumPy

Write the maths of the ML videos directly as code.

In this lesson10 parts

  1. 01The feature matrix, and one prediction by hand
  2. 02The same prediction in a Python loop over every row
  3. 03X at w: the matrix product, every row at once
  4. 04Star is element wise, and at is the matrix product
  5. 05Transpose with dot T, and the two pieces the solve needs
  6. 06A one dimensional array has no orientation, and the None index
  7. 07The normal equations, and np dot linalg dot solve
  8. 08Why not np dot linalg dot inv: the condition number, and lstsq
  9. 09Checking the weights against scikit-learn
  10. 10Recap and your challenge

Key terms

The words this lesson introduces, each in one line. The module’s glossary collects them all.

Transpose
Exchange axes of a two-dimensional array
Matrix product
Row-column combination written @
Linear system
Equations represented as A @ w = b

Quiz 5 questions

Your first pick on each question is the one that counts, and a right one earns a coin. Getting one wrong here is how the lesson sticks.

Practice

Problems to solve in your own notebook. Each states the problem, not the steps: working out the steps is the exercise. Level A applies the lesson, B combines it with earlier ones, C stretches it.

The self-checking notebook for this lesson is Axes and linear algebra.

Where it’s used

Where this lesson’s ideas turn up in real work.

Builds on

This lesson stands on its own. These go deeper into what it uses.

  • Maths Module 3