In the last video we saw how we might find some of the most ideal and parameters for our Random Forests
regressing.
But we only set the number of or in my case you might have done this differently you might have had
some more time.
But in the essence of time for recording these videos only set it up to two.
However in a previous experiment a.k.a. step 6 I set it to 100 and found some more ideal hybrid parameters
and what we have here.
So that's what we'll do.
We're going to in this video train a model with the best hybrid parameters and we'll put a little note
here and go No.
These were found after 100 iterations of randomized search CV.
And now if you were to do something like this like 100 iterations of randomized search CV you still
may find different height parameters potentially better height parameters the height of Rambus searching
like finding the best height around us from model is as we've talked about before and it's not an exact
science it involves a lot of trial and error a lot of experimentation.
So for this one you're just going to have to kind of trust me that I've run this 100 iterations it took
a couple hours on my mac so I'll just show you which ones we found so most ideal hyper parameters and
that way once we've gone through something like this or randomize search CV to find some ideal hybrid
parameters because this was only I'm scrolling back and forth here because this was only trained on
10000 examples what you'll probably do is use random search CV to find some ideal hybrid parameters
across a space like this on a subset because otherwise it would take hours and hours and hours and then
retrain our model on the full dataset which is what we're about to do now with the most ideal hyper
parameters that were found in randomize search CV.
So let's call this one ideal model and we'll settle up here.
Random Forest regress are so in my case an estimate as was 40.
Now this is interesting right because the default in random forest regress.
If we go here shift tab the default is 100 so it's actually from the randomize search CV it's actually
found that 100 estimate weren't required.
So 40 still provides pretty good results mean samples leaf was found to be 1 and then mean samples it
was found to be 14 and then Max features was found to be 0 point 5 and end jobs of course we're going
to set to negative 1 because we want our computer to use all of the processes that it has.
Well in my case I do Max samples equals none because why we want to train on all of the data.
So we set Max samples to none a.k.a. it will train on as many samples as possible.
And now we're going to fit the ideal model because it just instantiated above ideal model.
Don't bet on the training data ex train.
Why train.
And now this may take a couple of minutes.
So what we'll do I'll run this cell and again when a time travel and once the training is complete we'll
be out to see how long it took because we've got time and then we'll evaluate our model
beautiful.
So that took about one minute and 14 seconds.
Now that's on the entire data.
And the reason being is the main reason is because an estimate as is 40 rather than 100.
So what that means is the random forest is building 40 smaller little models rather than 100 so almost
two and a half times less.
And I did forget one parameter that we probably should have put in here random state equals 42 not going
to rerun the model now but just so it's there I'll put a little comment here.
Random state so this is so if we were to set an umpire random seed same thing random state so our results
are reproducible and here's how reproducible.
Yes it is a beautiful safe hours to run their cell again over and over and over with random the state
set to 42.
We would get the same model being fit but that took about 1 minute 14 seconds on my computer.
It may take a little bit longer a little bit shorter on your computer depending on how much processing
power you have and if you're running randomize search TV a number of times more than what we've done
up here.
You may potentially find different parameters to what I've found here and if you have I encourage you
to share them so other people can try them out and will evaluate it to see how they go to see whose
parameters are the real best ones.
So let's check it out with our handy show scores function and we'll pass it our model that we just trained
shifting into their beautiful and because this is trained on all the data we should see a significant
improvement over the model that we trained before.
So let's go up.
Here we go.
R.S. model.
Okay.
What we might do is bring these closer to each other so we can go scores for ideal model trained on
all the data and let's go here.
Scores on IRS model only trained on ten thousand examples the exact same line of code we ran a couple
of cells up from just doing it here so we can directly compare them all right.
So let's look at here the valid am SLA is especially the one we want to pay most attention to.
As you can see with our ideal model in one minute 14 seconds of training time it's gone through 400
or so thousand rows and reduced the valid M.S. Ellie M S Ellie.
Yeah.
That's a mouthful.
Bye.
What is that about point eight.
So that's pretty damn good.
And if we saw with this we were already doing well on the cable competition with our original model.
Let's see where our new and improved one which is our ideal model.
So we're looking at this here.
Valid root mean square log error.
Point 2 4 6 where does that get us on the leaderboard point two 4 6.
All right.
So around about there so 30.
So we're almost in the top 30 on the Kaggle leaderboard just in a model that took a minute to run and
going through here with the random forest regresses straight out a psychic learn.
That's pretty damn impressive and we haven't really done an incredible amount of data manipulation we've
turned our data into numbers we've filled missing value but we're already getting some incredible results.
So what will probably do is leave our ideal model there.
We could search for longer with randomized search CV up here and find some better height parameters
and probably slightly improve our model even more maybe push us right into the top 25.
That'd be pretty cool.
But what we might do now is see how we'd make a submission to Kaggle.
So what does this mean.
So if we come here.
How do you even get on the leaderboard.
Well if we go here to data to get on the leaderboard we have to make some predictions on test dot CSB.
So right now our predictions are invalid dot CSC but all of these scores on the leaderboard.
So really we are just guesstimating where we'd end up because we're predicting on valid CSP at the moment
we're evaluating our model on a validation set but if we come back to overview and evaluation what we
have to do is submit a submission file.
So okay submission file should be formatted as follows sales I.D. sale price so that's what we publish
might do now we might import the test data set and formatted in a way so we can use our machine learning
model on it and create an example submission in the format that Kaggle is asking of us.
So that sounds like a good plan.
Now we've got an ideal model we'll use that to make predictions on the test dataset.