OK so in the last section we saw how to choose an estimate how or machine learning model for the problem
that we're working on.
Do we have a regression problem.
Do we have a classification problem.
And we followed this flowchart through and we tried out a bunch of different models such as linear SPC
and ensemble classifiers a.k.a. the random ensemble classifier or the random forest classifier.
That's in and now in this section we're going to have a look at actually.
Let's revisit our what we're covering list so you've ticked off this and inside loan workflow Yep we've
seen getting the data ready Yep we've seen choosing the right estimate a slash algorithm for our problems.
Aha.
Now we're up to here three fit the models slash algorithm and use it to make predictions on our data.
Now we've kind of actually seen this Well we've seen the first half we've seen feeding the model.
Well we're going to have a look at both.
We're going to look at feeding the model and then use it to make predictions on our data.
So what we might do is go three is feed the model slash algorithm on our data and use it to make predictions
wonderful.
And then under here will produce section three point one is fitting the model to the data.
Now we've kind of got some code that will help us out for this already and again not in there.
I'm not a fan of copying pasting code but in the interest of time because otherwise we'll just literally
be re typing everything in this cell
but I trust you might have already done that.
So if not you can retype it out.
I'm going to copy that in here.
And the main line we're concerned about here is the fit.
So if we type in here go fit the model to the data.
So this re step through what we've got here because we didn't type it out we broke our rule but that's
a right from SBA loan dot ensemble.
Import random forest classifier This is saying hey SBA loan ensemble library import the random forest
classifier model.
We've set up a random seed.
We've split our data into x and y.
So X is a feature variables or the features or the data they're different names so I might put in here
or actually maybe up here x equals features feature variables.
Data.
They're just different names for X and Y equals labels or targets or target variables.
So different names for this is just so if you see where you're out and about see different names for
these two X and Y common variable names that you'll see in python.
But these are different like names that you'll be they'll be referred to right.
And so what is fit doing when it goes through here.
So let's have a look at X within visual here.
Right.
Not getting stuck in the theory of things.
So why not head this is x and y and what are we passing and why we're passing it.
The training data and training X and training y to our classifier.
So this is the fit function.
This is what we're concerned about fitting the model to the data what does fit actually do.
Well when we pass x and y to fit it will cause the model to go through all of the examples in X..
The training data in our case and see what their corresponding y label is and try to figure out the
patterns that lead to different combinations of numbers here.
What leads to having a one is a label or a zero as a label in the case of the bottom end of this.
Why not tail yes or a zero as a label that is fit in a nutshell right.
And how the machine learning model in our case a random forest classifier how this does is is going
to be different depending on the model you use and explaining the detail.
So remember all of these green ones here a different machine learning models and explaining the details
of each and every one would require an entire textbook or a much longer video course.
Right.
For now to become a practitioner to start applying machine learning code.
The most important thing you can remember is that it's kind of similar to how you would figure out patterns
if you had enough time.
You'd look at the feature variables in X the age the sex the cholesterol I'm not sure actually what
the rest of these are.
They're just different health attributes and you'd see what different values of these lead to different
values in y one for heart disease or zero for not heart disease.
This concept regardless of the problem is similar throughout all of machine learning.
So during training which is what the fit function is another term for fit.
So we want training.
Okay.
That's why we're using training training machine learning model.
The model is going to find patterns here and then during testing here.
Or when a machine learning model is in production it's going to use the patterns.
So use the patterns the model has learned that is the crux of all of machine learning right.
The way we become practitioners of this is starting off by first diagnosing what problem we're working
with and then coming in finding a model.
Now you can dive in as deep as you want to actually figure out the nuts and bolts of what a random forest
classifier does or what a random forest regressive does.
That may be a bit of an extension we work on in the future but for now that's the crux of it right.
If you want to figure out what a machine learning model does it take some data.
It finds patterns and then it figure out or in supervised learning it figures out how those patterns
relate to labels.
That's in a nutshell.
If you wanted to you can dive as deep as you like into each of these models not focusing on that for
this cause.
Remember our focus is to write machine learning code rather than dive into the theory if you like I'll
leave some extra resources on some deep dives into the random forest model which is the one we've been
using.
But for now we've finally seen how we've heard what the crux of machine learning is finding patterns
in data.
We're gonna see how we can this is three point to make predictions using a machine learning model.
So now that our models have learned patterns in the data by calling the fit function how can we use
what it's loaned to make some predictions on data.
The model hasn't seen we'll have a look at the next video.