Mathematics for machine learning

Books

Informal articles

Mathematics of Machine Learning blog

Linear algebra

Matrix manipulation

Calculus

Statistics

Bayes

Probability

Why probability probably doesn’t exist (but it is useful to act like it does)

Complex numbers

Formal proofs

Natural Number Game


Software tools


Syntax ref: Numpy einsum

$a_m = m^{th} \text{ element of } \mathbf{a}$

$\mathbf{a}_m = \sum_m{\mathbf{a}}$

$\mathbf{a}_{(m)} =\text{ all of } \mathbf{a} \text{’s } m \text{ elements} $

One-dimensional array:

>>> a = np.array([1, 2, 3, 4])
>>> np.einsum("m->", a)
10
>>> np.einsum("m->m", a)
array([1, 2, 3, 4])

One-dimensional arrays:

>>> a = np.array([1, 2, 3])
>>> b = np.array([-4, 5, -6])
>>> # dot product
>>> a @ b
-12
>>> np.einsum("m,m->", a, b)
-12
>>> # Element-wise product
>>> a * b
array([-4, 10, -18])
>>> np.einsum("m,m->m", a, b)
array([-4, 10, -18])

Higher-dimension arrays:

  • Einsum form of $ A_{(i),m} B_{m,(j)} = im,mj -> ij $
>>> A = np.array([[1, 2], [-3, 4]])
>>> B = np.array([[0, 1], [1, 0]])
>>> A @ B
array([[ 2,  1],
       [ 4, -3]])
>>> np.einsum("im,mj->ij", A, B)
array([[ 2,  1],
       [ 4, -3]])

Equations ref

Classical ML Equations in LaTeX