Mathematical Notation

Under the hood machine learning is based on math. The math is relatively simple and you are not required to know more than basic linear algebra, calculus and probability theory. Skills that you can improve as you progress in this block.

The complexity and confusion often arises not from the math itself, but from mathematical notation. Unfortunately this notation is not always consistent from paper to paper, from book to book and from author to author, so you really need to make sure you understand the intentions of the authors.

Generally speaking we will utilze the notation that reduces the friction between math and computational implementation, in other words once you understand the math you should be able to understand the code automatically and vice versa.

We are not going to completely reinvent the wheel, but instead utilize already established notation in books and courses. Mostly we will use the notation used by Sebastian Raschka in his books[1] and courses. The book by Sebastian Raschka is in our self-study recommendation list and should thereby create some familiarity.

To clarify the mathematical notation we are going to use the example of a dataset that contains the features of a house and the corresponding target (price).

Distance to City CentreSizePrice
201002000000
3030800000
4040700000
30601700000

We start with the representation of the feature dataset undefined . The dataset is an undefined Matrix with undefined number of samples (rows) and undefined number of features (columns).

undefined

The superscript undefined is used to display individual samples in the dataset and the subscript undefined is used to display the features in the dataset. For example undefined references the 5th feature in the first sample of the dataset.

If we apply this notation to the houseprice dataset we get the undefined representation for the feature matrix.

undefined

Often we want to show calculations for one single sample in the dataset. For purpose that we use row vectors, represented by bold, lowercase letter undefined .

undefined

The labels are represented by a column vecor undefined of size undefined .

undefined

In the house dataset the price is the label represented by the vector undefined of dimension undefined .

undefined

The weight vector that is used to scale the input vector undefined is represented by the bold letter undefined .

undefined

Info

We do not expect you to learn the above notation by heart. The intention is to have a reference that can be used to return to, if this becomes necessary. Nor do we assume the notation to be complete. The notation above is the foundation that is fundamental to all machine learning topics. Each section will enhance the notation to suit the needs of the section.

References

  1. Raschka S., Liu Y. Mirjalili V.. Machine Learning with PyTorch and Scikit-Learn. pp. 9-11. (2022).