A New Appreciation For Maths

I don't want this post to turn out with that soppy, transcendental tone that I read so often and slightly cringe at. I feel I just had an important experience that reinforces a recent change in attitude towards maths and its role in my work.

I have always been driven by the pursuit of pragmatism. Tell me an idea, and I will ask where I can use it. This has led to an interesting relationship between maths and myself.

During early high school I had a natural aptitude for maths. I remember in year 7 I placed in the top 0.1% of the country for a national maths contest. I got a nice $50 check and the feeling I pulled off a great fluke. In school I always felt maths was the easiest subject and relatively straightforward, but over time my advantage in the subject relative to my peers fell off for two reasons. Firstly, I was a lazy individual who subscribed to the theory of 'maximum marks, minimum effort'. Secondly, the carrot the school hung in front of us was changing from a natural interest in maths towards a pursuit to increase the trailing digits in the final mark that the government says sums up all your achievements in education. Thankfully I didn't want to be a doctor or a lawyer, so I couldn't care less about squeezing the rightmost digits of that score.

I hoped university would instill a newfound love of maths, but this was not the case. All that had changed was that now the lecturers were interested in demonstrating their academic superiority by explaining relatively simple concepts in rigorously defined and tested terms that lost all meaning to my practical mind. There were exceptions to this (thank you to Peter Brown, my Finite lecturer) however my mind was settled on the matter.

In my first year of university, 5 out of the 9 courses I studied were maths courses. That might sound like a love of maths, but it was a desire to get it done with as quickly as possible.

  • Maths 1A (Linear Algebra / Calculus)
  • Maths 1B '
  • Discrete Maths
  • Finite Maths (fields, number theory, error-correcting codes)
  • Probability, Stats and Information

I did the bare minimum to skate through, but managed to get distinctions in most of them and a HD in Finite. On paper, I was a great student who could demonstrate an understanding on all the topics discussed. In reality, I had put my many years of high school examination preparation into practice to hone in exactly on the style of questions that I knew would surface. It really is an extroadinary skill I had developed, to know exactly what I was required to know and not waste my cranium on the remainder.

While I did apply some maths knowledge in other domains, the problems were usually of such simplicity that I attributed any success to common sense, or so contrived that I felt I was being tricked into seeing the usefulness of it. If I wanted to discover the applications of maths for my field of work, it wasn't possible for someone to show me, I had to find it out for myself.

In S1 2014 I studied AI. No disrespect to Alan Blair (lecturer, now my thesis supervisor), but the first half of that course I found utterly disinteresting. All credit to Alan, the last half of the course contained some of the most interesting things I had learnt at university. Decision trees, Neural Networks, Deep Learning. I was inspired. There was little discussion of the implementation, I knew I had to use a sigmoid function and calculus to facilitate backpropogation, but surely someone else had wrapped that in a nice little box for me and that would be that.

Fast forward to the last 6 months. I have elected to do a thesis on Robust Recommeder systems (collaborative filtering algorithms resistant to collusion). I knew I liked the idea of machine learning, but I didn't know what I was getting myself into.

"What is that?"
"A vector, why is that a vector"
"They're all vectors"
"How do I multiply a matrix and a vector again"
"L-2 Norm, that sounds complex, I'll come back to that"
"I see the algorithm, but what am I trying to minimise?"
"Wait, that's inverse?? I thought that was transposed??"
"WHY ARE THEY ALL VECTORS, please just give me scalars, I like single numbers, they are easy and logical"

Yeah, I freaked out a little bit. But slowly I have been picking it all up again. In an academic pursuit. Slowly but surely I am learning my first year maths again and gaining back my linear algebra intuition. But still, I don't plan on going into research, someone else will make a library for me to do this when I go into the wild.

The Practical Application

At work last week, I had to create a program that makes predictions. I won't go into details about for what purpose, but it involved using linear regression on a small sample of datapoints, but this method was applied to thousands of different instances (with the hope to scale to millions later).

Easy I say. I grab Apache Spark's MLLIb, solve the problem with Linear Regression powered by SGD. Done.

Oh no, MLLib is overkill for such a small amount of datapoints per instance (<100), let me try another library. Great, Apache Commons Maths has an OLS regression implementation. No mucking around with gradient descent or setting parameters for that. Just a mathematically pure minimisation.

Oh no, the model grossly overfits. The pursuit for a mathematically pure minimisation fit the data well but was a horrible model.

No worries. I'll just use a regularised version of this. Let me just open up the libarary ... wait, it's not here. Cue me spending several hours scouring the internet to find an appropriate library to use.

Finally I thought I would take the plunge. I looked up the appropriate wikipedia article and got to work convincing myself the equation was correct, what all the variables meant, how it was derived, etc. I implemented it in 10 minutes in Scala, and it worked exactly as I expected. There was an inherent beauty in the solution, and the fact that a few seemingly unrelated and abstract matrix operations could combine with the help of calculus to provide a model for the data.

This may not be earth shattering, but I feel it is the first time I have used non-trivial university level maths to solve a real problem I have had. It felt good. I was able to solve a problem with no library to do it for me, and that I understood mathematically exactly what the algorithm was doing and how it was derived.

It is a thing of beauty when such abstract concepts combine to deliver a result that adds real value to our world. Hopefully I'll be more aware of when these situations arise in the future, and be more eager to solve them myself (when appropriate) rather than spend time searching for a library that will be 'good enough'

Subscribe to ha.mi.sh

Don’t miss out on the latest issues. Sign up now to get access to the library of members-only issues.
jamie@example.com
Subscribe