Best Maths Resources for Machine Learning

Blog
Author

Dylan Gallagher

Published

November 3, 2023

Why learn maths anyway?

I’ll start by saying that if you just want to use machine learning libraries, especially the more beginner-friendly ones like fast.ai, then you don’t really need to know much maths at all, it definitely helps, but it’s not at all necessary. If, on the other hand, if you want to dive a little deeper and learn how and why these algorithms work as well as they do, then taking the time to learn some of the maths is a worthwhile investment.

By far the most important areas of maths that machine learning is based on are: - Linear Algebra - Calculus - Probability and Statistics

I’ll discuss these one-by-one and give you my recommended resources for each of them.

Linear Algebra

Linear Algebra is used a lot in machine learning. Data in machine learning models are represented by matrices. Once you learn about matrices, as well as fundamental operations on matrices such as matrix multiplication and the transpose of a matrix, you’ll find that a lot of dauntingly-complex concepts such as neural networks are nothing more than matrix multiplications. There are many other applications of linear algebra in machine learning, and these include Support Vector Machines and Principal Component Analysis, but we won’t go into them in this blog post.

Now that I’ve hopefully convinced you of the importance of linear algebra, here are some great resources:

Khan Academy: Linear Algebra

Khan Academy is a staple in education and the Linear Algebra section is no exception. He explains everything very well and it’s relatively easy to follow. If you just want a quick treatment of linear algebra, this is the resource for you. There’s no practice problems, which is a real shame because that’s where I found a lot of my understanding came from. An introductory linear algebra textbook can solve this problem. I picked up an older edition of ‘Elementary Linear Algebra’ by Anton for not much on eBay, which had many practice problems. It also served as a useful reference for linear algebra.

3Blue1Brown : The essence of linear algebra

3Blue1Brown’s YouTube channel is aimed at the mathematically curious. His ‘essence of’ series are some of his best content in my opinion. This series of videos can be watched before, after, or during a more traditional linear algebra course. It doesn’t teach you everything there is to know about linear algebra, but that’s not its goal either. The videos are made up of intuitive visualisations that help you understand the fundamental operations beyond just the formulas.

MIT OpenCourseWare: Linear Algebra

If you want to go sligtly deeper into linear algebra, then this is the resource for you. This is a full university treatment of linear algebra. The teacher, Gilbert Strang, is amazing, I cannot complement him enough. His lectures, alongside his book, provide some of the best explanations of linear algebra concepts I’ve seen anywhere. This course is quite tough, especially compared to the Khan Academy one, but if you complete it, you’ll have an excellent understanding of linear algebra and its applications.

Introduction to Linear Algebra - Gilbert Strang

This is the accompanying book to the MIT lectures. If you are watching those lectures, I highly recommend this book. It’s amazing. I find it much better than Anton’s book. It is a bit more expensive, even second hand, but it’s definitely worth it in my opinion. This book (and the accompanying lectures) are all you need to master linear algebra. The questions at the end of the chapter start manageable, but then get really tricky, which I think is a good thing.

Calculus

Calculus is another fundamental concept in machine learning. You can get by quite well with just a secondary-school-level understanding of calculus. As long as you know what a derivative is and what it represents, that’ll get you a long way. However, learning more advanced topics such as Multivariable Calculus is extremely helpful in the context of machine learning, as the functions we are working with are in high-dimensional space. If this sounds interesting to you, these resources will be very helpful.

Professor Leonard

Professor Leonard has an amazing series on YouTube covering everything from the basics of limits all the way up to multivariable calculus. These videos are recorded in a classroom and I found myself paying a lot more attention to this style of video compared to the electronic blackboard videos of Khan Academy (although they’re still great). He goes at a nice pace, and his explanations are amazing. He also does a lot of worked examples which helps a ton. The book which he follows is by Stewart. I started that book, but I wasn’t a huge fan of it, but then I found Thomas’ Calculus, which I’ll talk about now.

Thomas’ Calculus

This book, much like Stewart’s book is a fairly standard Calculus book. You’ll end up learning the same stuff from either but I much prefered the explanations in this book. It’s also readily available second hand on eBay for a lot cheaper. I used this book in conjunction with Professor Leonard’s videos. This combination will give you a comprehensive coverage of Calculus. The questions in the book are varied, some being more mechanical ‘plug-and-chug’ while others focused on applications.

Probability and Statistics

Covering Probability and Statistics will round up your maths foundation nicely, letting you focus on the ML-specific theory without having to jump back and forth between maths and ML. Probability and Statistics come up all the time in AI and Machine Learning. From simple classical ML models like linear and logistic regression all the way up to cutting-edge diffusion models, having a basic understanding of probability and statistics will help you immensely. So, without further ado, here’s my list of recommended resources:

Khan Academy : Probability and Statistics

Khan Academy saves the day again! This course on probability and statistics starts basically from scratch, which can’t be said for all the resources on this list. It assumes very little of the student and starts from the basics like the mean, median and mode, and ends up in relatively advanced statistical tools like ANOVA. This series should be all the probability and statistics you need for your machine learning journey, but that being said, if you’re interested in learning more, the next course on the list is very good.

STAT 110 - Harvard University

I’ll start by saying this course is intense. Joe Blitzstein is exceptional at explaining the concepts, but there’s no getting round the fact that you’ll most likely struggle. There is a free book that goes with the course, written partly by Joe Blitzstein, which goes into more detail about the topics covered. The requirements for this course are hefty enough, you’ll need a really good working knowledge of sets as well as quite a bit of calculus. He recommends at least being familiar with multivariable calculus, which does help understand certain related topics in probability. Overall, it’s a great course. I recommend checking out the first few lectures to get a feel for the pace and difficulty and maybe come back to it after doing the Khan Academy course if it interests you.

And that’s about it!

Now I wouldn’t necessarily recommend learning all of this maths before diving into machine learning. Learn by doing! A lot of the concepts of machine learning become so much clearer when you actually implement them in code, so if you are following a machine learning course or book and get stuck, try coding it out first before jumping to the conclusion that you ‘need more maths’, because you probably don’t.

Anyways, that’s been my two cents on the topic. I hope you enjoyed.