Hello everyone, welcome to this short video on Escalon random forest model. In this video, we are going to predict whether a person has heart disease or no, using a basic random forest model. The variables that we will be using are 8 sex, chest pain and so on and so forth. There will be 13 such variables that will be using to predict whether a person is going to have heart disease or no. Now, the last variable that is the target variable is the one that will tell us whether that person has a heart disease or no. And we are going to basically call this as the Y variable. Now, let's look at the random forest model. First, we are going to begin by importing pandas as PD and we are going to import random forest classifier from under the umbrella, SQL learn on some well method. Let me first load the libraries, then let's load the data set. The data set is present in this particular location. So, basically, I am going to put that location here and get the data set. Now, once I have the data set, let's check some of the rows within that particular data set. Within the data set, I have the 14 variables that are there along with the target variable. Now, we are going to model on the target variable. The rest of the variables are going to be called as X variables. Let's check if there are some missing values. Fortunately, there are no missing values. So, we are just going to go ahead and do the next step. Then, what we'll do is now we'll get the target data within Y variable and from the data set, I'm just going to take the target data. Whether a person has heart disease or no, this particular variable will be telling us. Now, next, we're going to load the X variables, drop just the target variable so that the rest of the variables are going to be with you. I've run this and print the shape of the X variables. You'll notice that there are 300 rows, 303 rows and 13 variables. Now, this is what our basic modeling setup is going to be looking like. For the next steps, what we're going to do is we're going to divide the data into train and test. So for that, we're going to take the SQL learn model selection, train test, split method and divide our data set into four different data sets. Now, once I do the division, let's check out all of the data sets and their sizes. The X train data set will have 242 rows, which is roughly 80% of 300 3 rows and 13 columns. The Y train will be 242 rows, same as the X train and it will only have one column which will be which will be basically 0 or 1, the target variable. Similarly, we have X test and Y test. They'll have 61 rows, which is nothing but 20% of 303 approximately and obviously 13 columns, much like the X train. Also, it will have 61 values for the Y test, which will tell us whether that particular person has a hard disease or no. Now, we're going to build the model on the train data set and then on the test data set, we're going to check if that accuracy is holding good enough or not. So let's build the first basic random forest model. First, we're going to initiate an instance of the random forest classifier into RF model. Now, I've done that. I'm just going to fit the model RF model.fit and this time, I'm going to use the X train and Y train data set to basically fit the model. Now, once I fit the model, there are a lot of parameters random forest has and it has basically chosen some of the best ones that it could take. In the random forest, there are some parameters that are very helpful and then we can use parameter tuning. There'll be the criterion, max depth, max features, max leaf nodes, max samples, max impurity, max sample leaf, max sample leaf split, N estimators is one of the most important ones too and jobs, OOB score and then random state and some other ones that are available. So basically, there are a lot of parameters that we can tune within random forest. In the next video, we're going to be looking at the random forest model with hyperparameter tuning. So for now, we're just going to focus on building the basic model and see how the accuracy looks like. Generally, when we do a random forest, there is an OOB score that is available. In this particular model, since it's false, we're not going to be looking at that particular score. We're just going to be looking at the accuracy of it. If I run this particular accuracy here, you'll see that the train accuracy is one which means the random forest has overfitted this training data, which means that it's not going to be doing good on the test dataset. And like I said, the test accuracy is around 0.885, which is a big difference to the train accuracy that we have here. Essentially, random forest, yes, it does good, but it's also known for overfitting the model to really fit a good random forest model. What we need to do is use the hyperparameters and grid search to identify a good model that will also have a good test accuracy along with the train accuracy. Basically, it's balancing the bias and variance to build a good model. So our next video, we're going to be doing random forest hyperparameters tuning. Thank you for watching this video guys. If you like this video, please hit the thumbs up button and please don't forget to subscribe to my channel.