Welcome back.
We left off the last video asking the question how do we improve this school.
And what if Ridge wasn't working.
Then we kind of referred back to our machine learning map here.
What I might do is put this link in here and go.
Let's refer back to the map
link there.
And I'm one of pull up here.
Step one.
Check the socket line machine learning map.
Now you can find this pretty easily right.
By searching socket line machine learning map.
Now what we're getting here.
Remember how.
Right at the very start we talked about how we're getting focused on just writing machine learning code
deciphering what problem we're working on and then finding the right model for it and applying that
model.
That's exactly what we've just done here.
We've discovered what our problem is.
We've imported our data.
And we want to use these characteristics about different towns and cities to figure out the average
house price and so that's what we've done.
We've deciphered our problem gone to the machine learning MAP AND GONE HEY WE'RE GONNA GO FOLLOW THIS
THROUGH.
AND NOW WE FOUND ridge regression because we answered a few questions to get us to here and we figured
well that's not working so we might try something else.
And that's where we get upon to ensemble regresses let's close on that and see what it says ensemble
methods.
The goal of ensemble methods is to combine the predictions of several base estimate is built on with
a given learning algorithm in order to improve generalize ability.
That's a big word slash robustness robustness.
Farhad I can't speak over a single estimate.
Now what this means is it's essentially combining a whole bunch of smaller models.
So imagine if we used 10 different range regression models and we combined them and asked them to score
each other and then we average that score.
That's the premise of ensemble methods.
And why am I talking about ensemble methods.
Well that's where random forest come from.
Forests of randomize trees and now the reason why we go straight to randomized or randomized trains
because it's kind of like the war horse of machine learning right.
Random Forests.
You see it's got a classified version and a random forest regress.
That's why we're focused on it almost no matter what structured data problem you have and by structured
data I mean things that you find in a data frame or a table something that looks like this if there
are patterns between the features and labels a.k.a. these columns in the target column chances are a
random forest will find them at least somewhat.
So that's why we're focusing on the random forest and ensemble methods.
Now how can we use an ensemble method.
Well from S.K. lone dot ensemble import random forest classifier define x and y instantiate the random
forest classifier and then fit it huh that seems pretty straightforward.
In fact we've actually seen this but let's see it for our particular problem.
So we've tried the read regression model let's try the random forest.
So how do we do this guy from a sky line dot ensemble.
Import random forest Progresso.
Now we're going to set up a random seed because we like our results to be reproducible and beta random
seed and we love the number 42.
Then we're going to go create the data we could actually even just copy everything here.
Copy that and do it again but we're going to get in the habit of really getting used to this kind of
setup could copy that sub out reach for random forest aggressor but we're not going to do that we're
gonna write it down so create the data ex Eagles Boston data dot drop and we're gonna remove the target
access equals one.
Wonderful y Eagles owner and this is Boston def wrong name Boston IDF want to use the target column
here.
Wonderful.
Split the data X train x test y train y test equals train test split.
X Y test size equals zero point two.
Beautiful exactly the same code as above.
And then we're going to go instantiate random forest regress.
We're gonna call that model equals or maybe we'll call it something else just so we can quickly compare
it RF equals random No.
We need capital.
What can we do tab.
Would I complete random forest regress.
Yes we can.
Wonderful.
We're going to R F don't fit our f stance short for random for us.
Ron I've just made that up.
Why train and then we want to go evaluate the random forest aggressor that makes sense beautiful.
So our f y test is that correct.
Mm hmm.
Before we even run it what do you think will happen here.
So does it look kind of similar to this while in fact it does it is kind of gave that away before but
let's run it.
If in doubt run the code we get this little warning here because again in the future if you're using
zero point two two or socket loan zero point two to or above an estimate is which is a hyper parameter
here is gonna be set to 100 so we can remove that warning by setting an estimate as to one hundred eight
point eight 7 3.
Now what did our ridge get point six six six.
Well that could be an omen napkin model not scored just so we can see them side by side.
Maybe put a little comment here like we know what's going on.
Check the range model again x test y test and we know they're using the same splits here because we've
set up a number by random seed so we go to model school so on the same data right we could even comment
this out in a cell just to be sure.
Well commented out
Oh that's even done better there.
And you know why that will change even though we've got a random seed.
It's because there's some sort of randomness within random forest regress hence random forest.
It means it's randomly creating models every time you run it.
So if we did this again so just by using a different model we improved our score by point two to about
that so pointed to.
But you can clearly see that this number is bigger than this number.
And that's all from just defining what our problem wants and then paying attention to our machine learning
map.
So this is kind of what you want to do at the start of every machine learning problem or project that
you're working on is figure out what kind of problem that you're trying to work on.
Is it regression are you trying to predict a number.
Is it classification.
Are you trying to predict whether something is one thing or another.
Is it clustering or is it dimensionality reduction.
So once you sort of know what problem you're working with then you can follow the steps in this flowchart
and figure out which side can't learn estimates or a.k.a. machine learning model you can use.
So what we're going to do next.
That's an example of working it for a regression problem.
You can probably try this ahead of time if you want.
If you want to be a daredevil like that you see if you can choose which estimate you should use for
a classification problem.
Start here.
Go through here use the heart disease dataset we've been working for heart disease dot CSC and see if
you can figure out which one it is.
Or you could kind of just scroll up and see the code we've written before but let's set that up to point
to.
This can be choosing an estimated up for it's a classification problem.
And we'll remind ourselves.
Let's go to the map Excellent.
So that's why we're gonna cover in the next one.
We've seen what it's like choosing one for regression problem and now we're gonna see what it's like
for a classification problem.
I'll see in the next video.