‫All righty.
‫So we've seen how to choose an estimate for a regression problem.
‫How can we do the same for a classification problem?
‫Well, first of all, let's get a data set that is a classification problem back in our myths.
‫So we want data.
‫We've already imported this above, but we're just going to do it again just so we have it.
‫See as V just to make sure it's the same heart disease, heart disease, dot head.
‫Wonderful.
‫So again, we've seen this data set before.
‫We want to use these columns of patient.
‫Each row is a patient, so each sample is a patient.
‫Each column or each feature is a health attribute of that particular patient.
‫And the target, one or zero, is whether that patient has heart disease or not.
‫So our model classification, predicting something is one thing or another, heart disease or not.
‫That's what we need.
‫So what we're going to do is we left ourselves this little link here to go visit the map.
‫So we're going to pay attention to that.
‫We go here?
‫So we know we want something in the classification realm, but what we're going to do is we're going
‫to start from the top.
‫And follow this through.
‫So start.
‫Do we have above 50 samples?
‫Well, let's check.
‫Each row is a sample.
‫So we want Len.
‫Hot Disease 303.
‫Yes, we can.
‫Are we predicting category?
‫Are we hot disease or not?
‫Hot disease sounds like a category to me.
‫Yes.
‫Do we have label data?
‫Yes.
‫Do we have under 100 K samples?
‫Yes.
‫What is this?
‫We reach a little green box.
‫Beautiful.
‫So remember, the green boxes are estimators or machine learning algorithms.
‫So let's have a look.
‫This is telling us our problems classification.
‫And maybe the first one we come to is trying a linear SVC.
‫Well, all right.
‫Classification SVC and linear SVC.
‫Are classes capable of performing multiclass classification on a data set?
‫Well, this one particularly said linear SVC.
‫So let's have a look.
‫Linear support vector classification similar to SVC with parameter col linear but implemented in terms
‫of lib linear rather than lib SVM.
‫Whew.
‫That's a lot of terms there.
‫And most of them I don't really understand.
‫But what, what's important here is that if we go down to the code example.
‫We can see.
‫From scalar and SVM import linear cvc xy0.
‫They've used x and y.
‫Classifier equals linear SVC.
‫All right, this is kind of similar.
‫Well, let's not take the documentations word for it.
‫Let's try it for ourselves.
‫We'll go import.
‫Actually, we'll leave ourselves a note consulting the map, and it says to try.
‫Linear SVC.
‫So that'll be our first port of call.
‫Import the linear CVC.
‫Estimate a class.
‫Want to go from Skyline Dot SVM.
‫And really what I'm doing here is I'm basically just going to rewrite this but for our problem.
‫So scale and on spvm in Portland, the SVC.
‫Import linear sv c.
‫Wonderful.
‫Set up random seed and paid out random don't seed and we use our five for 42 and then we're going to
‫go make the data.
‫We saw this in the previous section.
‫Section one get your date already.
‫X equals heart disease.
‫Don't drop.
‫I want to get rid of the target column on axis equals one and y equals heart disease.
‫Why is actually the Target column beautiful?
‫And then when we go split the data.
‫X test or no train comes first.
‫Silly me, I've done this about 100 times by now and we're still getting it wrong.
‫See, this is what it takes.
‫It takes a little bit of practice or it takes a lot of practice to start applying.
‫Start becoming machine learning practitioner.
‫Knowing how to deal with data.
‫Knowing how to split data.
‫Knowing how to model data.
‫It's all part of the practice test size.
‫Yes, that is correct.
‫That's what we want to do.
‫Instantiate Linear SBC, so we'll call it self short for classifier linear CVC and we're going to go
‫that'll do actually say a left don't fit we want X train, y train and then we're going to go evaluate
‫the linear as we say self don't score X test, y test.
‫All right.
‫Beautiful.
‫Let's say this in action.
‫Wonderful live linear fail to converge.
‫Increase the number of iterations.
‫Ah well this is one of those things where if you came into an error like this, what I might do is go
‫convergence warning.
‫I google this message and see what came up because I've had a little bit of experience with it.
‫I might do something like Max, it equals 1000.
‫And it still happens, right?
‫So increase the number of iterations we've done that we've gone max, it equals 1000.
‫But this is actually how much does it start?
‫Max Iteration odds default by 1000.
‫Let's see, 10,000 still there.
‫Well, let's bypass that for the time being.
‫We're getting a warning and see here, the score is below 0.5.
‫Now, why is that a trigger in our heads?
‫Well, because if we look at our data.
‫We won't.
‫Heart disease target.
‫Don't value Kant's.
‫So we say there's only two classes, one or zero.
‫Does someone have heart disease or not?
‫Right.
‫So it's a binary classification problem.
‫Binary meaning one or the other.
‫And our model is receiving a score of 0.47 returns the mean accuracy on a given test data and labels.
‫As I said, well, look into evaluation metrics in a in a future section.
‫But what you can imagine this is our model is only operating at 47% accuracy.
‫And why does that trigger us?
‫Well, because there's only two classes.
‫So that means if we were just guessing whether someone had heart disease or not, but based off their
‫health attributes, we were just guessing yes or no.
‫We would get 50%.
‫It's basically a coin toss.
‫So what's that triggering in our head?
‫It's saying, hey, without fixing this warning or without improving our model by tuning the hyper parameters,
‫our linear SVC model might not be finding patterns between X and Y.
‫So what can we do?
‫Well, when in doubt, come back to the graphic.
‫Not working.
‫Are we working with test data?
‫Because we just try linear we.
‫So we're going to say not working.
‫Are we working in test data?
‫No.
‫Well this is going to say K near is neighbor's classifier, but I'm going to skip this one.
‫I'm going to go to Ensemble Classifiers.
‫So let's click on this now.
‫Why this?
‫Because we've seen this before.
‫Ensemble methods, forest of Randomized Trees, Scale own ensemble from scale learn ensemble import
‫random forest classifier.
‫Now if you remember back up in our regression problem, when we switch to using a random forest aggressor,
‫we saw a bump in the score.
‫Well, because random forest regression did so well.
‫Good news is for us, it's got a dance partner called Random Forest Classifier.
‫We've actually seen this before, but what we're going to do is compare it to linear SVC.
‫So to save time, I'm going to copy this code and I'm going to bring it down here.
‫So we want to change this to random forest classifier.
‫We actually want ensemble import, random forest classifier.
‫Wonderful.
‫We can keep the rest the same.
‫Except for this.
‫We need to actually sub this our random forest classifier.
‫And we want to go random forest classifier.
‫Wonderful.
‫We'll do the same here.
‫Just to tidy up our notes, keep our code communicative.
‫Wonderful.
‫And now what do you think will happen here?
‫Three, two, one.
‫Let's see.
‫Error fit missing one argument.
‫Why?
‫Oh, there we go.
‫That's what we forgot.
‫We forgot to add.
‫Little brackets on the end are a wonderful way to get rid of this warning.
‫We need to change an estimate.
‫US could see here the default value of an estimate is will change from ten inversion 0.2 to 100.
‫So we'll just get rid of that by changing an estimate.
‫US equals 100.
‫Delicious.
‫Wonderful.
‫So what's happened here?
‫We've used a different model.
‫Now, linear SVC has scored 47% accuracy and our random forest classifier has scored 85% accuracy.
‫So nearly, nearly double by just using another model.
‫Right.
‫So you can see why I'm kind of jumping to using random forests.
‫And if we go back.
‫All I've done is I've gone start.
‫I figured out what kind of problem we're trying to solve.
‫You can do this as well.
‫So for our regression problem, we were trying to figure out whether something was a number for our
‫classification problem.
‫We were trying to predict a label.
‫So we have label data?
‫Yes.
‫Are we predicting category?
‫Yes.
‫And now our linear SEQ model wasn't working, so we went straight to ensemble classifiers.
‫And now you might be thinking, what about all the other models?
‫Right.
‫So we've kind of skipped all these ones here, all of these, and we've only really touched the surface,
‫we've only used this one and ensemble classifiers for both.
‫And that's a great question.
‫Well, the first reason is namely for time, we could go through and try all of these.
‫And the second reason is there's a little tidbit in machine learning.
‫If you have structured data, IKEA tables or data frames, use ensemble methods such as random forest.
‫Why?
‫Because it will perform pretty well if there are patterns.
‫This is a tidbit here.
‫Heart disease.
‫Might write this down.
‫So we know.
‫I'll put this in a resources section as well.
‫Tidbit is one if you have structured data use ensemble methods, and two is if you have unstructured
‫data, use deep learning or transfer learning.
‫Now what's an example of structured data while stuff in a table like this?
‫And if we have unstructured data, which is like images, audio or text or something like that, use
‫deep learning or transfer learning.
‫Now we haven't covered deep learning or transfer learning yet, but since we have structured data a.k.a
‫things in a data frame, the tidbit there is use ensemble methods, which is hence why we've kind of
‫gone, you know what, I'm not going to try any of these.
‫I'm going to straight to ensemble classifiers, straight to the random forest, because the random forest
‫is known for its robustness and ability to find patterns.
‫Now.
‫Whew.
‫We've covered a lot.
‫We've had a look at this.
‫Machine learning map if he's still looking at this going, holy gosh, what's going on?
‫Don't worry, it took me a while to figure it out too, but it really clicked once I realized, Hold
‫on, the first step is to just get the data.
‫Figure out the main problem we're trying to solve.
‫Usually regression or classification.
‫They're the two most common ones you'll come across and then start answering the questions, going through
‫it, and then use a little framework, something as simple as this to start running machine learning
‫estimate or machine learning model on your data and getting some feedback from it quickly.
‫That's the most important part.
‫I mean, a data scientist or machine learning engineer is reducing the time between your experiments.
‫So what we're going to do now is we've seen how to choose a model.
‫We're going to get into the next section, which is fitting a model to the data and then using it to
‫make predictions, because that's really the essence of machine learning, right?
‫Finding patterns in data and then using those patterns to make predictions on future data a model hasn't
‫seen before.
‫Take a quick break and I'll see you in the next video.