‫All right, let's see how we can tune the hyper parameters of our logistic regression model using grid
‫search CV So grid search CV Beautiful.
‫And if we put a little note here.
‫Since our logistic regression model.
‫Now, remember, it's it's quite confusing.
‫I still look at this and think it's a regression model.
‫This is a classification model provides the best scores so far.
‫We'll try and improve them again using grid search survey.
‫So if you want to look up the documentation for grid search CV, it's in psychic loan.
‫You can just search like it loan grid search CV and you'll see.
‫And it's an exhaustive search over specified parameter values for an estimate.
‫So what we might do is just recreate different type of parameter grid, so different type of parameters
‫for our logistic.
‫And again, if you want to find the different hub around, you can choose from a machine learning model.
‫In our case, logistic regression.
‫You could search something up like this.
‫So how to tune a logistic regression machine learning model in Python?
‫That's where we found things like what we're going to create here.
‫So log red grid, we've made this up here before, but we're just going to bring it down.
‫So we've got it in our line of sight log red grid.
‫So we're just basically put in the exact same thing.
‫So C equals NP log space negative for for 2020 different spots.
‫Actually, we might just for fun, you know, we're going to increase this to 30 because we're using
‫grid search.
‫Why not why not live on the edge, you know, create different parameter spaces that we haven't seen
‫before.
‫That's what life is exploring, things we haven't tried before.
‫That's where all the fun is.
‫So we'll go set up grid, hyper parameter, search for logistic regression, we'll go GTS log rig equals
‫grid search CV that needs a little capital there.
‫Maybe we'll use tab to complete for this is because we're we're keyboard ninjas here.
‫Now the difference between randomized search CV and grid search CV is this little hyper parameter here
‫in Grid Search CV.
‫It's just called param grid in randomized search CV it's called parameter distributions.
‫So then we'll pass it.
‫This our new log rig grid, which has 30 intervals between negative four and four on a log space because
‫we are living dangerously here and CV equals five and then we're going to go verbose equals true.
‫Just to put out our little outputs of what's happening now.
‫You'll notice there is no Neta here.
‫Unlike in randomized search CV, there's an ETA because grid search CV tries every single combination
‫of parameter in here and finds the best one.
‫So we want to go fit.
‫We've saved this.
‫By the way, our logistic regression grid sets to G's log rig for GTS is for grid search, so fit our
‫grid hyper parameter search model when the full gas log red dot fit x train, y train and then we go
‫boom, run.
‫It's going to fit five candidates because totaling 150 fits over 30 different sets of height parameters
‫because we have set CV equal to five and it's done already because logistic regression is nice and fast.
‫And so check the best type of parameters and go, jeez, log rig dot best params.
‫Wonderful.
‫Okay.
‫So you've got to see value of that really long number solver is live linear.
‫Well, we kind of guess that because there's only one option there.
‫How can we evaluate this?
‫We want to evaluate the grid search, logistic regression model.
‫So we use our test set again.
‫So jeez, log rig dot score on our test data, X test, Y test.
‫And let's see.
‫88.5.
‫Did we get any better?
‫Come back up here.
‫So if we look at our randomized search log rig, we got 88.5 as well.
‫Are the later decimals different?
‫No, the exact same.
‫Well, it looks like our randomized search and how subsequently I think our baseline logistic regression
‫model got that same score.
‫Subsequently, the logistic regression model has done very well.
‫That's pretty good for a model that doesn't appear in this classification map.
‫So so I can't learn.
‫I think you guys need to put logistic regression in here because otherwise people are going to be missing
‫out on it.
‫So that's something to keep in mind, right?
‫Is that although you find these these maps and these cheat sheets online, it still helps to do your
‫own research and not just rely on this handful of stuff that's going on here.
‫Because, remember, we know how broad machine learning is.
‫Like, just look at this.
‫There's just a lot going on here.
‫But even within these little bubbles themselves, there's still more that can be done.
‫So that's I can't stress enough how important it is to try your own research.
‫Okay.
‫So now we've tuned our logistic regression model using grid search.
‫We get the same results as before, even with increasing the number of different parameters that our
‫logistic regression model was searching over.
‫What we're going to do now is probably stick with this logistic regression model.
‫We could spend a little while on this hyper parameter tuning, like going through different resources
‫here, like this one here, high parameter tuning.
‫We may be able to squeeze out another percent or a couple of percent of accuracy, but for now we've
‫got a few requests from our boss.
‫I remember she was telling us earlier we need to have a look at the following high parameter tuning
‫feature importance.
‫What's that?
‫Okay, well, we've done hyper parameter tuning.
‫We've figured out logistic regression is probably the model we're going to stick with for now.
‫We've got a confusion matrix.
‫We've done a bit of cross validation through randomized search, KV and grid search.
‫We need precision recall, F1 score classification report, rock curve area under the curve.
‫Mark Goodness.
‫All right.
‫Well.
‫Let's do it.
‫So that's probably what we're going to do over the next few videos is use our grid search, logistic
‫regression, use our logistic regression model with its best type of parameters that we found using
‫grid search to get the things like the RC curve, the confusion matrix, the classification report,
‫the precision, the recall, the F1 score and all those other classification goodies that you should
‫use with every classification model.
‫So maybe you want to try a few different parameters with grid search by searching out something like
‫this.
‫That can be a little extension, but otherwise we'll move on to the things that our boss is asking for
‫us to make sure that we're reporting our results and our classification models correctly.