So the beautiful thing is now that our data has no missing values and has turned all into numeric values
we should be able to build a machine learning model.
So let's do that.
We've instantiated one way back up here as model.
Ray back when this we started the modeling section far we've covered a fair bit of ground here.
You should be proud modeling.
Wonderful.
We're going to do basically the exact same thing.
So let's build a machine learning model we could copy this but we're just going to write it out again
or leave a bit of communication to ourselves.
So now that all of our data is numeric as well as our data frame has no missing values we should be
able to build a machine learning model.
Wonderful.
So remember what our goal is.
It's to find patterns in the data to predict the sale price.
So that's what we'll have to do.
Let's have a look DFT HAMP.
Go ahead.
One last look at our data before we model.
So we need to drop the sale price column so that we can build a machine learning model that takes in
all of the other columns except for sale price finds patterns and then tries to predict sale price.
So what we're going to do I'm going to set up a little timer magic and if you haven't seen this before
the percentage percentage sign that's a Jupiter notebook magic function.
You can search out for a whole bunch of these.
But what this is going to do is basically just calculate how much time this particular cell takes to
run and I'm gonna do it on my computer which is a MacBook Pro.
How many rows do we have.
We have four hundred thousand or something rows.
This may take a little while.
In previous examples when we've worked with less data our machine learning models have been pretty quick
right.
Because it's only have to sort through a couple of hundred rows.
But this is 420000.
I mean of course there are much bigger data sets but we're starting to get up there right.
We're in the hundreds of thousands of samples instantiate model.
So what this time thing is going to do is because it's our goal as a as a data scientist as a machine
learning engineer is to do as many experiments as fast as possible.
If you training models on all of the data all the time it's going to take a fairly long time.
So I'm just going to demonstrate how long it takes for my personal computer to use a baseline random
forest regressive model to find all the patterns in all four hundred twelve thousand rows.
So don't worry I'm not going to have to sit there and watch it run once we kick it off.
All are pause the video and then come back and show you how long it took the ways of thinking I want
you to start thinking about is when you're doing experiments start to think to yourself How can I reduce
the amount of time it takes between my experiments.
The reason being is because you're not always trying to do the right thing you're trying to figure out
what's wrong what doesn't work.
So that's the rationale between trying to speed up your time between experiments and as I typed as I
talk what we're doing here is we're just instantiating a random forest model.
We're gonna put random state equals 242 their random state equals 42 that way our results are be reproducible.
So this is all we're doing.
We've imported the random forest regressive class because we're working on a regression problem we're
setting end jobs to equal negative one because this is a fairly large dataset for what we've been working
with for now.
So I want to use all of the cause and my computer and I want random say Digg or 42 so our results are
reproducible and I'm going to fit the model to the data.
So this is our X and this is our y.
Remember we're trying to predict sale price based on all the other columns except for sale price.
So when I kick this off this would take a few minutes but I'm going to pause a video and because we've
got the little magic function time here we can see how long it takes.
So get ready to time travel in three to one.
All right.
We're back.
That was pretty quick.
So our model is finished and it says here at the wall time was six minutes and 58 seconds.
So it took about seven minutes to go through 412 thousand seven hundred roses is actually pretty good
right.
Think about how quickly you could look at that.
How long would it take you to go through 400 12000 different examples.
You didn't have to wait for that time because I spent it up but if you were to run this on your computer
it may take longer it may take less time depending on what sort of computer you have on running this
on a 13 inch MacBook Pro I think from about 2016 or something like that.
I'm not even exactly sure how much computing power mine has.
But it's a laptop so maybe not as much as a desktop anyway.
But you can imagine as these numbers of Rose started to really get up high this could start to take
a long time.
If our goal as machine learning engineers if our goal as data scientist is to reduce the amount of time
between experiments we're going to have to be pretty nifty when we try out different models when we
work on different data because waiting seven minutes every time even if this number was higher burner
cell to run that's going to slow us down a fair bit.
So we'll see a little trick soon of how we can improve this but finally score the model so see how our
model did.
If it's gone over four hundred twelve thousand rows surely it's found something some patterns in here.
So we're going to score it on just the exact same data that it was trained on so we'll copy this.
And now remember for regression algorithm the default score value here is going to be returned the coefficient
of determination which is the r squared.
Now if you need a refresher on what r squared is you can go what is co efficient of determination.
But in other words it's a score that can go up to 1 0.
If all your model does is predict the mean of the sale price column and it can go to negative infinity.
If your model is absolute terrible.
So we're looking for a value that's close to 1.
So again this might take a little while because the model has to compute the score of how it did across
four hundred twelve thousand rows
bomb point nine eight.
Wow.
If the maximum is four point nine eight seven so close at point nine nine.
So if the maximum is one point zero.
Does that mean a random forest regress has almost found a perfect pattern for finding predicting the
sale price based on it.
Are the columns in the data frame not so fast I want you to think about before we get into the next
video where we're going to cover it.
Why is this metric not reliable right.
So if we have a look here we fitted the model on this data and then we've evaluated it on the same data.
Why doesn't this metric hold much water have a think about it.
We'll talk about in the next video.