- HD
- 720p
- 540p
- 360p
- 0.50x
- 0.75x
- 1.00x
- 1.25x
- 1.50x
- 1.75x
- 2.00x
We hope you enjoyed this lesson.
Cool lesson, huh? Share it with your friends
About this lesson
Let's start talking about machine learning. In this video, we introduce linear regression and the least squares method.
Exercise files
Download this lesson’s exercise file.
What Is Linear Regression - Least Squares Method57.1 KB
Quick reference
What Is Linear Regression - Least Squares Method
Linear Regression, or Least Squares Method, is a form of machine learning that attempts to predict the future.
When to use
Use this method when you have a dependent variable and some independent variables and want to attempt to predict outcomes.
Instructions
Linear Regression is one of the more basic machine learning techniques. Throughout the next few videos we'll dive into it in greater detail.
Hints & tips
Login to download- 00:05 Okay, it's time to change things up a little bit and
- 00:07 talk a little bit about machine learning.
- 00:09 So we're not going to spend a whole lot of time talking about machine learning,
- 00:12 this is sort of the end of the course.
- 00:14 I just want to kind of whet your appetite and
- 00:16 show you a little bit of what's out there so you can start to think about what
- 00:19 you want to start learning next when it comes to data analysis with Python.
- 00:23 So we're going to be looking at linear regression,
- 00:26 which is sort of the most basic sort of intro thing in machine learning,
- 00:30 it's one of the easier models to do.
- 00:32 And we're going to walk through a linear regression in the next few videos,
- 00:35 like I said, we're not going to get into great detail.
- 00:37 In this video,
- 00:37 I just want to talk a little bit about what is linear regression.
- 00:40 So linear regression is a machine learning model prediction thing, right,
- 00:44 it allows us to make predictions of the future.
- 00:47 So think of it like if we know the height of different men, for instance, and
- 00:51 we know the average height of men, and a man has a child,
- 00:54 we can sort of use linear regression to predict how tall that child will be.
- 00:58 Things like that, just future things that we can predict numerically.
- 01:01 So if we head over to Wikipedia really quickly,
- 01:04 you can look up linear regression if you want to read about this.
- 01:07 Basically what we're doing is we're creating a scatterplot like this with
- 01:12 data, and we're passing a best fit line through it.
- 01:15 And then we can use that line to make predictions into the future.
- 01:19 So think of these as men's height for instance, right?
- 01:22 And given this data, if somebody up here has a kid, well,
- 01:26 we can sort of fit this line into the future to guesstimate how tall that
- 01:31 kid's going to be things like that, right?
- 01:34 So you have these points in this data, and
- 01:36 the thing you're trying to do is find the distance between the point and the line.
- 01:41 We call this distance the error, so we square this error,
- 01:44 and then we want to minimize that error in order to make predictions in the future.
- 01:48 So like I said, we're not going to get into this in great detail,
- 01:51 but that's basically what we're doing.
- 01:53 So we've done things like scatter plots before, we can we can do things like that.
- 01:57 So you may have heard of least squared errors method,
- 02:00 that's the same thing as linear regression.
- 02:03 And like I said,
- 02:03 we're just fitting a straight line just set of data points to make predictions.
- 02:06 So we need several tools in order to do this, we're going to use something called
- 02:11 Scikit-learn, which is a machine learning program for data analysis with Python.
- 02:15 We're going to be using something called Seaborn,
- 02:18 which is another charting system that's sort of like the Pandas and
- 02:21 Matplotlib we looked at in the last section.
- 02:23 Only the the charts and graphs are a little bit more fancy, but
- 02:26 they work in very similar ways to what we've already learned.
- 02:30 And we're also going to use SciPy to do some calculations and things like that.
- 02:33 So what we're going to be doing is running a linear regression on some
- 02:36 housing data from Boston.
- 02:38 So Scikit-learn comes with some sort of
- 02:41 dummy data that we can play around with and run our analysis.
- 02:45 So I'll walk you through just a basic linear regression analysis,
- 02:48 we'll take a look at it.
- 02:50 Hopefully, like I said, it'll whet your appetite, and show you sort of what's out
- 02:53 there, and what you could start to think about learning next after this course.
- 02:57 And like I said, we could spend hours and hours on machine learning,
- 03:00 we could spend hours and hours on linear regression, we're not.
- 03:03 We're going to spend 20 minutes or so, but it should be a good introduction and
- 03:07 kind of show you what's out there.
- 03:09 So in the next video, we will install all the things that we need to get started
Lesson notes are only available for subscribers.