Supervised learning problems - Part 2
Start course
1h 23m

Machine learning is a big topic. Before you can start to use it, you need to understand what it is, and what it is and isn’t capable of. This course is part one of the module on machine learning. It starts with the basics, introducing you to AI and its history. We’ll discuss the ethics of it, and talk about examples of currently existing AI. We’ll cover data, statistics and variables, before moving onto notation and supervised learning.

Part two of this two-part series can be found here, and covers unsupervised learning, the theoretical basis for machine learning, model and linear regression, the semantic gap, and how we approximate the truth.

If you have any feedback relating to this course, please contact us at


Let's look at some examples of regression. This is regression. What we're gonna do... Imagine, that we can visualize, well we don't need to imagine, let's just visualize some historical data set. In our historical data set, we would have a vertical, horizontal axis. Now so we wanna visualize tables and see what's going on with it. Well, we'll put on the vertical the thing we're trying to predict. Let's go for profit in this case because profit's sort of a nice intuitive sort of thing. Remember to say the thing that we know, that will allow us to predict profit in the future, would mean to be, how warm it is outside, in degrees centigrade, say? So, if it's a hot day, in our business we sell, you know, maybe we're an ice cream business, so we sell more ice creams on a hot day than we do on a cold day. So profit from ice creams will be our y, and temperature outside will be our x. Okay. Let's pull on the historical data. Let's do it red. So this is the historical data. So let's say, uh you know, let's say, temperature outside is freezing and maybe, 30 degrees, very, very hot. And then y, the number of ice creams we're selling. Well, let's say we sell zero ice creams, when it's freezing outside, say. But maybe we go up to in a day, profit per day, say. Um, maybe we sell, let's go for 100 pounds of ice creams. And on the hottest day, we profit 100 pounds. So we have an example in our historical data set, just one example of it being 30 degrees outside and making 100 pounds. Maybe we should have some other examples. Maybe it was 30 degrees but we made much less money. Maybe it was freezing outside but we made more than zero. You know we sold some ice cream that day. But generally speaking, of course, what we'd expect, is to see, that when we put our historical data set on this graph, there is a pattern. Sort of random. And in fact, uh, what this pound tells us is that the hotter it gets, the more money we make. Now that step, of drawing that line, that's machine learning, that's regression. That's solving a machine learning problem. This line here, solves, the machine learning problem. How does it do that? Well it connects, something we know, something we know in the past, in the past, but in the future, we only know this, but we can use this. Let's say that in the future, it's green maybe, is going to be 27 degrees outside. We know what temperature it is outside, but let's say we're trying to compute profit. Well how do we do that? We'll just use this line. Line, and then we go across and go here, what would that y be? Well our y would be this guess, and let's say our guess here is gonna be 70 pounds. So we, so our x in the future, is 27. Now our guess for y, is 70. And the solution to the problem is the f. This red line is the f, it's the connection, it's the connection. And we might know that here, this connection is a straight line connection, linear connection. And so the formula for f would be something like well, if I take an input of x, what I would do, is maybe I would, well if I'm going from twenty, if I'm going from 27 to 70. Let's say its 2x, and then let's add something, you know, so maybe 27 times 2 is 54. Let's add 20. I'm not saying, I'm guaranteeing, this is a perfect formula for that, for that line there. I'm just saying let's try out the formula. See if I put in here, if I put into this formula, 27, what does that do? Well it gives me 2 times 27. Which gives me, I think, 54. And I add 20 and that gives me 74. Okay, . So it's kind of where the line is there, so that's 74. What happens if I put zero in? If I put zero in, well I get 2 times 0 is 0. I get 20, so it tells me my minimum profit here is kind of like 20 pounds. That's my minimum profit at 0. And if I put in a much bigger number, let's say put 100, 100 degrees outside, that's never going to happen. But it will be 200 degrees centigrade, 220 pounds. 220 pounds, would I make 220 pounds if it was, if the air temperature outside was boiling, would boil water? I don't think so, I think everyone will be dead. But, apparently my line tells me I would make 220 pounds. So this gives us an insight to machine learning problems already, pretty good insight. Because, we can see that there's a region, a historical region almost, where we have seen things before, like between, between zeroish, and sort of 32ish or 33 degrees. And in this region, we have lots of data, which allows us to compute a really good line, a really good relationship f, that we can use in the future to give us an estimate y had, a prediction for profit. But actually, maybe there's a region, let's draw in a different color, that be red. Maybe there's a big, scary region off into the distance, high temperatures, 40 degrees outside, 50 degrees outside. Well we haven't seen anything before. And if we use our red line in that region, if we use the same relationship, which is being computed on a certain kind of history, when the future is different, then the line, won't be right. And our predictions will be very wrong. Perhaps, catastrophically wrong. I think maybe it's catastrophically wrong to think we'd be profiting if it was 100 degrees outside. That would be, that would give us a really strategic error, if we were relying on that. So it connects to what I was saying in the beginning of this, this course here, that, you know, we've got a weak AI system. A system which, looks at a specific data set, highest specific data set for a specific, you know, variables. And it's not gonna generalize. You know, it's not gonna generalize in the intelligence sense. It's not gonna sort of, this red line doesn't reflect, it doesn't creatively solve a different problem. It is just a red line. It's just that pattern that it is learned from a particular history. And it's gonna struggle if the data, , it's seen, isn't a lot like or very similar to, the environment in which it is deployed and it's similar temperatures outside. That's regression.

About the Author

Michael began programming as a young child, and after freelancing as a teenager, he joined and ran a web start-up during university. Around studying physics and after graduating, he worked as an IT contractor: first in telecoms in 2011 on a cloud digital transformation project; then variously as an interim CTO, Technical Project Manager, Technical Architect and Developer for agile start-ups and multinationals.

His academic work on Machine Learning and Quantum Computation furthered an interest he now pursues as QA's Principal Technologist for Machine Learning. Joining QA in 2015, he authors and teaches programmes on computer science, mathematics and artificial intelligence; and co-owns the data science curriculum at QA.