‫Alrighty then.
‫Now that we'd figured out different ways to evaluate our machine learning models, you're likely.
‫Next question is how can we improve upon these metrics?
‫And that's what we're going to cover in this next section, section five, which is improving a model.
‫So let's make a heading here.
‫We'll 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 are 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 try to improve upon that so a.k.a
‫improve your predictions and improve your model.
‫And 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 you do a bit more practice
‫than usual, you might get a little bit better at that at that thing, maybe not exorbitantly better,
‫but certainly if you do ten sessions of practice, you'll probably be a little bit better.
‫If you do one session of practice.
‫Same thing goes with machine learning, right?
‫If there's 10,000 examples rather than 1000 example of something, chances are if there's patterns in
‫that data, the machine learning model will pick them up.
‫And the second one is, could we improve our data?
‫Now, this is if you had, for example, in our 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 in 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've got a more depth of information within each sample.
‫And then what we're going to be focusing on is from a model perspective, and this asks a question like,
‫is there a better model we could use?
‫So if we look at the circuit learn machine learning map.
‫We've seen an example of this before.
‫So for example, when we followed it through and we started off with a linear SVC 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 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'll 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.
‫And 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 where you'll hear the term simple model versus complex model.
‫Linear SVC 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 referred to as more complex.
‫So that's kind of what we've already tried, right?
‫We started off with a simpler model and then we move 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 hyper 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 hyper parameters equals
‫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, right, 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.
‫Well, this is a little bit confusing here.
‫We might put a little heading here, hyper parameters versus parameters.
‫Now, how do you find a model's hyper parameters?
‫Well, that's a good question.
‫Let's check it out.
‫We'll go from Skyline Dot Ensemble import random forest classifier.
‫Clef equals will instantiate a random forest classifier here.
‫Random forest classifier.
‫Wonderful.
‫Now, once we have a model instantiated, you can find its hyper parameters by calling the function
‫on it.
‫Get params.
‫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, this is 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 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
‫learned kind of defines them as parameters.
‫The reason why it's 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 the socket, learn random forest, classified
‫documentation, and read through all of them and find out what what exactly they are.
‫And 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 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, if 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 at 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 hyper 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% 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, this is 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 in second line.
‫And the third one is exhaustively with grid search.
‫CV.
‫Okay.
‫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 in this section is we're 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 I'll see you in the next video.