Welcome back.
The last video we finished off checking it out correlation matrix and we looked at our workflow and
saw that we're now up to step five.
So we've covered problem definition data violation we've looked at the features we've done little bit
of data analysis now it's time to stop bringing in machine learning so let's see how we do that let's
go into here we'll create a little heading it might do it 5.0 modeling and we're gonna turn this into
markdown and so what's our problem.
Let's scroll back up.
We defined it up here right back at the star so problem definition is step 1.
So in a statement given clinical parameters about a patient can we predict whether or not they have
heart disease.
So we're working with the classification problem okay as what we're trying to be answering with machine
learning and evaluation.
So this our evaluation metric because right now we've got a dataset kind of we're just exploring it.
We're experimenting here.
So if we wanted to actually get this into production into a real life setting we'd probably want it
to be fairly good right.
Because it's predicting something as important as whether someone or not has heart disease.
So we want a minimum of 95 percent accuracy at predicting whether or not a patient has heart disease
during our proof of concept which is kind of like what working through here.
And if we can make it to that we'll keep pursuing it we'll keep going see if we can improve it make
it better or see what we need to improve.
So this is what we're gonna be trying to solve with machine learning we're trying to answer this problem
statement.
And this is our valuation metric something that we'll be working towards and of course each of these
could change but these are just give us a little roadmap or something we can head towards.
So let's go down see what we would do.
The first thing we might do is relook at our our dataset remind ourselves of what we're doing.
So we're going to be using these columns to try and predict the type column so a.k.a. the independent
variables to predict the dependent variable here and the first thing we might do is split our data into
x and y so we'll split it into features and labels and then what we might do is create a training and
test split so model what we did in the socket line section when we worked through the socket line machine
learning workflow.
So let's do that.
So let's go split data into X and Y
X is going to be equal to every column except the tiger column.
That's what we want to DFT drop we're going to drop the target.
We're going to set the axis equal to 1 Beautiful and then Y is going to be these are all labels.
So we're going to go DLF.
We can just go target there we go.
Now let's visualize x.
Wonderful.
No target column and we'll visualize y to remind ourselves it's just 0 1 whether or not someone has
heart disease a coronary classification because there's only two options.
Binary meaning 0 1 and now what we have to do is split our data into a training and test with.
Now we've seen this before but it's worth reiterating why not use all the data to try to model what
is a train and test split.
Well let's say you wanted to take your model into the hospital and start using it on patients.
How would you know how well your model goes on a new patient not included in the original full data
set.
Now we have so if we built a model on every single sample in this this data frame how would we know
how would we have an insight into seeing how it would go on someone that our model has never seen before.
This is where the test set comes in.
It's used to mimic taking our model into a real environment as much as possible or at least it tries
to as much as possible.
It's important to never let our model learn from a test set.
It should only be evaluated on a test.
So we're gonna have a training set which is like when you're studying for an exam it's like the course
material.
So the machine learning model is going to learn the patterns in the course material then it's gonna
be evaluated on the final exam which is the test set.
So let's say that what we're going to do is split data into train and test sets so to do so we can use
num pi random seed first so we can reproduce our results and we can split our data into train and test
sets using socket lines train test split.
So you go split into train and test set X train x test we saw a lot of this in the socket loan section
but it's paramount to reiterate that that whenever you try to test or whenever you try to evaluate your
model it should be on data that the model has never seen before test size and do the standard zero point
two.
So this X is what we've created up here now dependent variable.
And this is why which is our labels.
So now we're going to shift and into wonderful and we're going to have look at the training data.
So we've got X trying we can see that it's shuffled it and its scope 242 rows out of the total 303 rows.
So it's got about 80 percent of the entire rows.
Now we can do the same with the Y train and we might do find the land of Y train as well
y train is the same length as X train but it's only got the labels.
And so if we compared the indexes here it's got the labels for each of these samples 1 3 2 1 3 2 wonderful.
Now what do we do.
Well now we've got our data into x and y we've got train and test as well.
So we've got training data and we've got testing data.
The next thing is to build a machine learning model.
And we're working with classification.
This comes to a point where it's like what model should we use.
Now we've got our data split into training and test sets it's time to build a machine learning model
we'll train it.
So find the patterns on the training set and we'll test it use the patents.
So using their patent it's found on the test set.
But what machine learning model should we use.
Well if you remember in the socket loan section we checked it out the socket loan machine learning map
so we're gonna go in here.
Wonderful.
So this is our start.
So we followed this through we know we've seen this before we've got a classification problem we're
trying to classify whether or not someone has heart disease based on their health parameters based on
their medical parameters.
So what we might do is only try a few of these you could try all of them but we're going to try and
do is use cane neighbors classifier we'll use this one so if we open that in the new tab and then we're
going to also use our trusty random forest so we'll open that as well.
So ensemble methods is a random forest in here random forest random forest classifier that's what we're
after.
Yes beautiful how we got here.
The nearest neighbors.
Wonderful.
So if we look through that we'd see how we could use it.
But we're going to see this in practice.
But there's one more.
If we go back here back to our machine learning map and it's not listed on here I wonder why that is.
Well we're going to see it in the next video what it is.
I'll give you a little clue it's called logistic regression and you might be thinking Hey we're working
on a classification problem logistic regression has the word regression in it.
And why isn't it in this classification part.
Well that's a great question because I'm not really sure either but we're going to have a look at those
three models in the next video.
So we'll create them and we'll see how each of them goes.
Because remember we're experimenting now.
We're now modeling slash experiments phase and one part of the experiments phase is trying different
machine learning models so that's what we're gonna do.
We're going to try three different machine learning models and see how they compare with their results
on the test set and then of course we want the best one.
So let's do that.