All righty then.
Now that we'd figured out different ways to evaluate our machine learning models you'll likely next
question is how can we improve upon these metrics.
And that's what we're gonna cover in this next section.
Section 5 which is improving a model let's make a heading here will go five improving a model.
Now the thing to remember here is usually actually more often than not the first predictions you make
on a model.
I'm not its last right.
And these first predictions are often referred to as let's write this down first predictions equal baseline
predictions and first model is often referred to as baseline model.
What you'll try to do is as you go on is once you've made some first predictions and evaluated them
and once you've built a first model like a baseline model you'll try to improve upon that.
So a.k.a. improve your predictions and improve your model.
Now how can we go about that.
Well there's two main ways.
The first one is from a data perspective.
You'll ask questions like could we collect more data because more data means that a machine learning
model may have more of a chance to learn patterns within that data.
And there's a saying in machine learning is generally the more data the better.
And it's similar to how if you were to practice something right and if if you do a bit more practice
than usual you might get a little bit better than that thing maybe not exorbitantly better but certainly
if you do 10 sessions of practice you'll probably be a little bit better if you do one session of practice.
Same thing goes on machine learning right.
If there's 10000 examples rather than 1000 example of something chances are if there's patterns in that
data the machine learning model will pick them up.
The second one is could we improve our data now.
This is if you had for example an hour car sales problem where we're using the make the color the odometer
and the number of doors to try and predict the sale price of a car.
Now if you were given that information it would be kind of hard to predict the sale price of that car
right.
So what you would search for here is maybe more features about each car so you would have more information
about each sample.
So rather than just more samples you'd go to more depth of information within each sample.
And then what we're going to be focusing on is from a model perspective and this Rs question like Is
there a better model we could use.
So if we look at the psychic loan machine learning math
we've seen an example of this before.
So for example when we followed it through and we started off with a linear SBC and we figured out those
results aren't too good back in our classification problem.
So then we went up and tried an ensemble classifier and now what we mean by this is there a better model
we could use.
So if you've started out with a simple model could we use a more complex one.
And what I mean by this is when someone says simple model usually what you do is the models the first
ones you come across here are relatively simple compared to the ones you'll end up here.
And now the reason you start out with a simpler model is because generally these models are faster to
train on whatever compute power you have an ensemble classifier such as a random forest or ensemble
models in general are generally considered more complex because you're training a bunch of little smaller
models at once.
And so this is why you'll hear the term simple model versus complex model linear SBC is often referred
to as a simpler model and then coming up here to like ensemble classifiers because it harnesses the
power of lots of different models.
They're referred to as more complex.
So that's kind of what we've already tried right.
We started off with a simpler model and we moved to something more complex with the random forest and
then if we are trying something more complex like an ensemble method a.k.a. using our random forest
classifier is could we improve the current model now in this case if the model we're using performs
well.
Straight out of the box which is what our random forest classifier does.
Can we improve the hybrid parameters of this model to make it even better now.
A little note here is that patterns in the data you find that our machine learning finds is often referred
to as data parameters.
And the difference between parameters and hyper parameters is a machine learning model seeks to find
patterns in data on its own.
So a machine learning model will find parameters in data on its own whereas hyper parameters are settings
on a model that you can adjust.
So we'll put this here.
Parameters equals model finds these patterns in data and high parameters Eagles settings on a model
you can adjust to.
Now we'll put this in brackets because this is a bit of a trial and error process to potentially improve
its ability to find patterns now we've covered a fair bit of ground not just in this one cell before
we've even seen to code but this is kind of setting up the framework for what we're going to cover in
the next couple of videos.
So let's put that there.
Oh this is a little bit confusing here.
We might put a little heading here hyper parameters this parameters.
Now how do you find a model's height and parameters.
Well that's a good question.
Let's check it out.
We'll go from S.K. line dot ensemble.
Import random forest classifier F equals will instantiate a random forest classifier random forest classifier.
Wonderful.
Now once we have a model instantiated you can find its hybrid parameters by calling the function on
it get parameters.
Wonderful.
Now these are all different hyper parameters that we can adjust on our random forest classifier.
And now if you're looking at these and thinking wow there's a lot here.
This is very confusing.
I'll show you where you can find out more about each one.
Well let's go to S.K. learn random forest classifier
wonderful.
So if we were to go through this documentation what we're going to see here is parameters.
Now this can be where it gets confusing because I've used the word hyper parameters but psychic line
kind of defines them as parameters.
The reason why as parameters here is because in Python terms each of these is a parameter that you can
pass this function to adjust.
But in reality these are hyper parameters.
So this is where this list comes from.
If we were to read through all of these we could come to this I learn random forest classified documentation
and read through all of them and find out what what exactly they are.
Then if we come down here so I could learn all include a few notes about the random forest classifier
and little tips on how we can adjust the hyper parameters.
Now the same goes for any other model that you might choose.
If you click on any of these you'll come across something similar like this documentation which will
tell you the models hyper parameters that you can adjust.
Okay now you still might be thinking I'm still not getting the concept of hyper parameters and so we
come to this little diagram this may help your understanding improving a model via hyper parameter tuning.
So if we imagine this food source here as our data and what we want a machine learning model to do is
figure out the patterns that it can use to make our favorite dish.
If you're cooking your favorite dish.
This is you cooking here not a machine learning model what you might find is that if you put the oven
on for one hour at 180 degrees your favorite dish the roast chicken dish doesn't come out exactly how
you want it but after a little bit of practice after a little bit of trial and error you find that if
you cook it one hour at 200 degrees your dish comes out exactly how you want it perfect.
Now the analogy here to understand is that in our case adjusting hyper parameters is like adjusting
the temperature on the oven.
Our initial machine learning model straight out of the box.
Maybe this this oven here cooking at one hour 180 degrees and it may find some patterns in how to combine
these ingredients together to get our favorite dish but it might not be just exactly how we want it.
So what we do is we try a few different parameters a few different type of parameters and eventually
we figure out we want to change the temperature to 200 degrees and that brings out our perfect dish
just the way we like it.
The same thing goes with our machine learning models.
If we just used our random forest classifier as it is as it came out of the box with its default parameters
these ones here it may find patterns in our data pretty well which it is it's doing about 85 percent
accuracy.
But what we might be able to do is adjust these much like our setting on our oven and so that it finds
these patterns in the data a little bit better than what it does straight out of the box.
Now again there's a lot to take in but don't worry.
It took me a while to understand this concept as well.
So we're going to look at over the next few videos three ways to adjust hyper parameters.
The first one is by hand.
So we'll try and tune them by hand.
The second one is randomly with random search CV which is a function in its socket line.
And the third one is exhaustively with grid search saving OK so have a little bit of a read over this.
Just read through here.
If you don't fully grasp it yet that's completely fine but just remember this is what we're going to
cover and this section is going to improve a model focused on hyper parameter tuning and hyper parameters
are settings on a model you can adjust to potentially improve its ability to find patterns in data much
like if you were cooking your favorite dish you might adjust the temperature of your oven from its baseline
setting of 180 degrees to get the perfect outcome of your favorite dish so keep that in mind and we'll
see you in the next video.