A concise guide from zero to one. 100% knowledge, 0% fluff. ๐
1/13
Functions, the central objects of mathematics and computer science, are just mappings of inputs to outputs.
A convenient (albeit quite imprecise) way to define them is to describe their effect. An explicit formula is often available, which we can translate to code.
2/13
However, giving an explicit formula is not always easy or possible.
For instance, can you calculate the number of ways we can order a deck of n cards by shuffling its cards?
3/13
There is a solution besides giving a formula.
Suppose that we shuffled n-1 cards. Given a new one, we can insert it into the deck at n possible locations.
Thus, all the possible shuffles of n can be obtained by shuffling n-1 cards first, then inserting the remaining one.
4/13
Counting this way gives rise to a formula that references itself. This is called recursion.
For the computation to end, we have to supply a so-called boundary condition. In our case, this is simple: a "deck" consisting of 1 card can be shuffled only one way.
5/13
Every recursion has two crucial components: the recursive step and the boundary condition.
6/13
In practice, we can simply implement recursive functions by calling the function in its definition. Most programming languages support this.
Frequently, recursion is an extremely convenient way to write clear and concise functions.
7/13
However, recursion is a double-edged sword.
Let's talk about a case where the recursive step involves referencing the function multiple times.
The famous Fibonacci numbers provide an example of this.
8/13
Just like previously, we can easily supply a recursive function to compute the n-th Fibonacci number.
Can you think of any potential issues?
9/13
For each call, the function calls itself two times. Those make an additional two calls individually, and so on.
This is how the recursive calls look for n = 4. (Each arrow represents a function call.)
10/13
As you probably figured, this can blow up really fast.
Essentially, computing F(n) this way involves an exponential number of calls to F.
11/13
Just out of curiosity, I have measured the time it takes to compute a few Fibonacci numbers with the recursive function.
F(40) took more than 30 seconds on my computer. I had no patience to wait out F(50).
So, recursion can be really slow.
12/13
TL;DR: a recursive function is one that references itself in its definition. They are powerful, but can be really slow.
Can you think of a better way to implement the computation of the Fibonacci numbers? Share your ideas below! (I can think of at least three.)
13/13
โข โข โข
Missing some Tweet in this thread? You can try to
force a refresh
The single best way to get into machine learning is to build something with it.
Here is an extensive list of hands-on projects that you can start right now. Take inspiration, learn tools, and find the topics you are passionate about.
Read on and go create something awesome. โ
I am grouping the projects into the following categories.
These hands-on projects work the best when you
โข follow along and do the coding as well,
โข understand why and how things work,
โข and try to bring what you built to the next level.
The reason PhD school is difficult is not because of the research.
Besides that, there are several key choices whose importance is underestimated by the students. Most of them are unrelated to your hard skills.
Here are the most impactful ones. โ
1. Picking your advisor.
Young researchers usually value fame and prestige over personal relations. However, your advisor and your fellow labmates will determine your everyday work environment.
Don't sacrifice this for some scientific pedigree.
A healthy relationship with your advisor is essential for your professional performance. Pick someone who is not only a good scientist but a good person as well. Avoid abusive personalities.
Interview students and lab alumni about your prospective advisor if you can.
There is one big reason we love the logarithm function in machine learning.
Logarithms help us reduce complexity by turning multiplication into addition. You might not know it, but they are behind a lot of things in machine learning.
Here is the entire story.
๐งต ๐๐ฝ
First, let's start with the definition of the logarithm.
The base ๐ logarithm of ๐ is simply the solution of the equation ๐หฃ = ๐.
Despite its simplicity, it has many useful properties that we take advantage of all the time.
You can think of the logarithm as the inverse of exponentiation.
Because of this, it turns multiplication into addition. Exponentiation does the opposite: it turns addition into multiplication.
(The base is often assumed to be a fixed constant. Thus, it can be omitted.)
๐ค Should you learn mathematics for machine learning?
Let's do a thought experiment! Imagine moving to a new country without speaking the language and knowing the way of life. However, you have a smartphone and a reliable internet connection.
How do you start exploring?
1/8
With Google Maps and a credit card, you can do many awesome things there: explore the city, eat in nice restaurants, have a good time.
You can do the groceries every day without speaking a word: just put the stuff in your basket and swipe your card at the cashier.
2/8
After a few months, you'll start to pick up some language as wellโsimple things, like saying greetings or introducing yourself. You are off to a good start!
There are built-in solutions for common tasks that just work. Food ordering services, public transportation, etc.
3/8