So how does machine learning actually happen in practice? 1
I mean it can't just be magic, right? 2
In this lesson you and I are going to establish a useful framework for thinking about machine learning techniques. 3
This is going to be our basis for thinking about the gradient descent algorithm. So at the most basic 4
level what we're doing is feeding a whole bunch of data into a computer 5
and it gives us back some solution, some answer. 6
The thing that our computer is actually learning is the relationship in the data. 7
So how is it that we can feed a whole bunch of data into our Python program and our program spits out 8
a function that describes the relationship in this data? 9
What are the steps involved in how our machine learns this mathematical function? In a very simple linear 10
regression example, 11
our machine learning program has had to learn the orange theta zero and the green theta one parameters 12
in this equation. 13
And that's going to be on the basis of the data points that it was given. 14
So you can keep this example in mind in what I'm about to describe to you, but this framework that we're 15
going to talk about goes well beyond regression and that's because many, many, many machine learning techniques 16
follow pretty much the same three step process to arrive at their solution. 17
And here it is - step one is to make a prediction, predict what exactly? Well, the coefficients in our function 18
for example, the theta zero and theta one. Our machine is learning a function, 19
so it has to start by predicting the coefficients in that function. 20
Now, the very first time this happens the very first prediction is pretty much like a completely random 21
guess. 22
So let's move on to step two. 23
After making the prediction, 24
step two is calculating the error - 25
in other words we need to measure how good the prediction was. 26
We need to calculate how far off we were from the data and that's why we calculate the size of our error. 27
And step three is the learning step. 28
This is where we adjust our initial prediction. 29
And this is the crucial part, right? 30
First we made a prediction. 31
Second, we compared our prediction to the data and now it's time to learn from our mistakes. 32
Yeah. 33
Having figured out how far off we were in the previous step, we can now make a change to the coefficients. 34
But, we're not done just yet, 35
right? 36
This was only the first run through. At this point, 37
we're going to go back to step one and make a new prediction. 38
This new prediction is going to have our modified coefficients. 39
So using this new prediction, we once again calculate how badly we did and calculate the error. 40
Hopefully this time round the error is smaller than the first time round. 41
So, having measured the error and how badly we did, we adjust our prediction once again and then rinse 42
and repeat. 43
So, in summary, there are three steps. Number one is predict or infer the theta values of the function. 44
Number two is calculate the error and measure how far off we were in our prediction from the data. 45
And step three is making an adjustment to have a smaller error 46
the next time round, and slowly learn the best coefficients. And this is the learning process. 47
When we're writing our Python code in this module, this is how we can think about training our machine 48
learning model. 49
Now there is actually a name for this kind of step by step approach that we just described. 50
This is called an algorithm. An algorithm is a set of instructions for solving a problem. 51
The Cambridge Dictionary defines an algorithm as a set of mathematical instructions or rules that, especially 52
if given to a computer, will help calculate an answer to a problem. 53
You know, the thing is you and I are probably more familiar with a different usage of this word, right? 54
Having heard sentences like "My app uses an algorithm to predict if fans of one particular band will 55
also like music from another band." 56
So it's perfectly understandable that most people think that the word algorithm is actually a word used 57
by programmers when they don't want explain what they did. 58
So before moving on to the next lesson I'm going to leave you with a fun fact. The word algorithm actually 59
gets his name from a guy, right? 60
Mohammed Ibn Musa Al-Khwarizmi. Al-Khwarizmi, algorithm. 61
Now I probably didn't pronounce that right but 825, 62
yeah a thousand two hundred years ago this guy wrote a best selling book in mathematics and the Latin 63
translators in the Middle Ages did an even worse job than I in pronouncing this guy's Persian name. 64
So, that's how we get stuck with the word algorithm. 65
So anyhow, on that bombshell, I'll see you in the next lesson. 66
Take care.