OK.
And the last video we trying to model on a subset of data a.k.a. allowing each estimate.
So one hundred estimate is to see ten thousand different data points rather than all four hundred thousand
or so.
And we saw a fairly big decrease in computing time.
So our model try and faster now what we might want to do is because we can experiment a bit fast and
now is try to find some ideal hyper parameters that are a bit better than what our random reforest regrets
are defaults with.
So let's have a look.
And if you've had a think about it you might have come across or thought of the idea of churning high
parameter tuning with randomized search CV something that we've looked at in a previous project in some
other previous videos.
So that's what we're going to have a look at.
And so wondering what randomize search CV is remember we can always look at the docs but what we'll
do is actually maybe we'll just create a cell.
Let's have a look at the code first from S.K. learn how would we import it model selection
randomized search CV and remember whatever machine learning model you're working with.
You can always go insert the model name so in our case random forest regress are hyper parameter churning
and this will give you some information on how to share in your Random Forests regress our or your random
forest in general so that's one way to do it the other way is from the way that we've seen is randomize
search CV are actually let's be real here.
There are many different ways to do it but if I remember what randomize search CV does if not that's
okay randomize search CV
go the documentation.
So random I search on hype of remnants basically we create a parameter distribution which kind of looks
like a dictionary and randomize search CV is going to take our model or estimate or in socket loan terms
and search across this Perak distributions or dictionary for the best type of parameters for our model.
So that's what we're going to create.
So different random forest regress are hybrid parameters and we'll go here are F grid nice and simple
for the dictionary.
This is the parameter distribution that I was talking about and we might go over an estimate.
Remember if you're wondering where these came from.
Don't forget you can always search up here random forest regress our revenue tuning and you'll find
a fair bit of information on basically almost any machine learning model that you can think of of different
ways of how to tune the hybrid remnants.
Because again this is not a perfect science.
This is a whole bunch of trial and error trying to figure out how things are going.
And so what I'm doing here is I'm setting up a number of different values that randomize search TV is
going to go through.
Try a certain number of calculations or combinations of them and then figure out which ones achieve
the best results because that's what we're after right.
We're after a model that boost us on the cable leaderboard.
That's what we're trying to do with our default model with no churn type and parameters we're sitting
and only 10000 examples mind you that's the bigger one there.
We're sitting at around eight here.
So that's not bad.
So what else are we turning here.
We've got a number of estimate as max depth.
These are all different parameters of the random forest means samples split mean samples LEAF AND THEN
WE'LL GO MAX features.
That's another good one zero point five one square root order.
And then we also might go Max samples so we might also set this to 10000 because we saw that before
Max samples increase how fast our model can find patterns in the data because it's only looking at 10000
random examples rather than 400000.
That's in our training set.
So in the spirit of trying to reduce the time between experiments we'll set that to that instantiate
randomized search CV model.
We'll call this RSS model really creatively randomized search CV and we'll pass it a random forest regress
the with end jobs equal negative one and also random state equal to 42 for consistency remember that's
similar to setting any random seed and then we're going to pass it our param distributions which is
our F grid which is what we've just instantiated up here and and ETA we usually do it for about 20 or
so.
Well I like to do it for about 20 or so for the first time but we might change that we might see why
CV equals five member that's cross validation with those ego's true and the reason why we're going to
reduce this probably only do it.
How much time do we have.
Maybe only two.
Reason being as you might well what has happened here to maybe that read really fast.
I'm not sure why would you like that in a second but that's a right.
Maybe five five is enough because I've already gone through this this process but I've set an it to
100 but it took like two and a half hours on my machine so you could set this to whatever you want whenever
you have time for but start low because if we were to set this to 100 this cell might run for a couple
of hours and say well if we were going home we might set this to run for 100 and run overnight or something
like that.
Or if we had a lunch break we might set it to run over our lunch break.
That's what I used to do when I was working at a technology company in my city I would run models over
my lunch break and while I was eating food and the computer was just calculating away in our case we're
just gonna set this to five and what we'll do.
That's why it ran so long because we didn't even fit it.
That's why this time is so small as model fit.
So what this is going to do actually two's enough then because I thought this confuse me but I realized
we didn't fit anything that's why it went so fast.
So is what we can do.
We go fit the randomized search saving model.
What this is going to do.
It's going to fit two iterations so randomize said she is gonna pick two different combinations of parameters
from here.
Assign them to the Al random forest or aggressor and then fit it to the training data.
And remember it's only on 10000 samples for the maximum and it's gonna tell us while we'll be out to
find out in a second which are the best parameters.
So because we're doing two iterations and we're doing a CV value of five there's still going to be 10
different fits.
So this might take a minute or so.
So we might time travel again and I know we said we can only time travel every so often but we unlocked
a superpower going through this project because we're doing so well with time travel until the cell
is done and we're back so that took my macro program just under two minutes right.
To try out two different iterations with five fold cross validation across a bunch of different hyper
parameters and now even though this took about two minutes it's still far less than our original seven
minute model trial that we did right and a few videos ago because we've set Max samples to equal 10000
and now because we have a trained model with randomized search CV we can find the best model hybrid
parameters that randomize search CV found for us.
And remember we've only sent this to two.
So if you have more time or more compute power you might set this to something like 100 and find the
best parameters from that but we're only doing two for this case when we go.
Here are a model dot based programs it's gonna tell us.
Okay so this is what the best parameters that it's found.
Ninety estimate is mean sample split 16 means samples leave 10000 Max samples because it was only 1
value Max features auto max def 10 and now remember these might not be the best model hybrid Romney's
because we've only searched for 2 different combinations but we're going to work with them for now evaluate
the randomized search model show scores our beautiful show scores function we're gonna pass at the IRS
model now we may or may not see an improvement here in our evaluation metrics that we've used before
yeah.
So we actually see that this has worsened.
That's okay right.
Because as I said we've only tried two different combinations and now in a past notebook in a past project
when I was setting up for this project I have actually as I said tried an ETA equals 100 and I took
a little break and I went in had some food because it took my computer just over two hours and so we'll
have a look at the best type of parameters my computer found in two hours of searching and we'll have
a look at how they go in the next video.