Let us see how we can do feature selection, so the first thing which we will be doing is we will import
numbers and find this.
Now, after importing.
The basic preprocessing, the all we have to do, which is removing the null values, so the first thing
which we will be doing is we will remove the null values and whatever null value is present, we would
either remove the entire rule or we will impute the mean value or median value or the more the value
of those places where null values.
What olelbis?
The second thing which we will do is we will convert the categorical variables into one Hawtin for doing
all, we can also see dummy variables.
And the ordinary variables in numeric variable, we can convert those into numeric.
Now, let us look at a data, so I'm importing a bank full data so it does a bank related dataset.
So in this particular data, we have these problems, age of marital status, education, void, violence,
housing loan gone by the month duration gap in the baby's previous outcome.
By now out of these values, these are only a few problems which we have now in a real life dataset.
There would be a lot more number of problems.
They could be around three hundred thousand or two thousand of five thousand number of columns.
Now, to find out only 10 or 20 such columns, which would actually give a good amount of information,
is a very difficult task.
So how we do it, we do it using feature selection.
So for selection, the first thing which we will be going with is bonders profiling.
So we will import profiling report from Binder's profiling and find that's profiling.
We have a profiling default option.
So we will run this profiling support function on the data frame.
And we can also export this report, which we have generated to a particular file.
So here I am just reading a file to your report filing and it is a.
So this is the fire which it has generated based on the size of this fire generation, might be a longer
time period because it will be analyzing all the columns in the data.
So it may take a lot of time.
So let us start analyzing the data, let us see what all we have found out in this particular report.
So the first thing that we have followed this, that the number of video booths is 17 and there are
forty five thousand round number of observations.
There is no missing since and there is no duplicate through.
So if there were any missing values, then we would have had to imbue the values or remove the rules
of data based on how much values are actually missing, then based on the duplicate rules, in case
there are any duplicate rules, then we would have deleted.
They was also.
Then this is just the memory of how much memory this takes, then it tells us about the video tapes,
what will be built up.
So it would tell us about what are the numeric variables.
So there are seven numeric video with six categorical variables and four boolean variables.
Then the next thing which we get here is how many dead body blows up and then how many variables are
rejected.
So it will automatically provide us with the number of columns which it will suggest to reject.
So these columns could be rejected on the basis of if two columns have a lot of correlation between
them or if the columns have high multiple linearity or the columns have a huge amount of null values.
So on those bases, it was suggested what columns has this Findus profile suggested as to Turin's?
So because this is a very small dataset, it has not provided any rejections, but it has provided a
few warnings, such as the balance column has a seven point eight percent zero values.
So increase the balance values had around to 80 percent or 90 percent zero values, then we could have
thought of removing that particular column.
Then here we have a previous column, which has around eighty one percent, so we can think of removing
this particular column because it has a very high amount of Zettl values.
Next, it gives us details about each and every variable, that is how many unique values are there?
What are the distinct number of values and the mean value?
The minimum number value, the maximum value and how many zeros are present.
So all the details are provided here.
So based on these details, we can actually find out what we need to do for them.
So if there are any missing values, we can again figure out how we need to improve these values.
And for those, we will again get the idea by seeing the plot.
So in case the plot is kind of symmetric in nature, if it is a normal plot, then we can use any of
mean or median or in case the plot is, you can just.
Then that is we would use the median of the plot.
So these are a few things which we will have to care of.
Now, here you can see that seven point eight percent value Z also that has been highlighted here.
And you can see the values on usually ranging from minus eight thousand to around one hundred and two
thousand.
So this is the range of this particular data.
So like this, we can see different things like here in categorical variables, you can see that there
is a very low amount of data for the telephone while there is a high amount of data for cellular.
So we can have only one category, cellular or cellular, instead of having three categories itself.
So this is how we can decide how many categories we need to have.
So here we have data about the.
And here we have data about education.
Here we have job categories, so here you can see that there are around other values where 40 percent
of values that others, then 21 percent of values for blue collar, 20 percent of the base for management,
and 16 percent of the base for the nation's.
So here are the further details offered.
So here we can see that around five percent data is for retired and all of the above categories have
more than five percent data in them.
So what we can do is we can decide the threshold value that we can have at least thirty five three point
five percent data in one column only with those categories we can consider for creating the categories.
So in that case, we can ignore these categories and the dummies for only these columns.
Only these categories.
Here are more details.
Then we have the correlation matrix.
So this shows what is the poor relation?
So in this, that is a very nominal correlation, there is not much information here in Spearman's,
again, you can see that there is a very, very, very high correlation between bidets.
And previous.
So these are a few things that we have learned from here that bidets and previous is very highly correlated.
Then there is a meaningful relation in other values.
Then you can see there are no missing values, and this is how the first few rows and the last few rows
look like.
So these are a few things which we get from this profile report, and similarly, we can learn a lot
from these reports and we can decide what all we need to do for them.
Now, the next things which we have is.
So based on this report, we can decide what we need to keep and what we need to do now, here is another
report which I have written for the breast cancer dataset.
So here we have around thirty three columns in both.
Out of which the last volume contains usually not a number values.
So here is the profile of the.
So it has actually provided us what all Gollum's we can project, and it has rejected 11 columns for
us so you can see how important this is, it has provided us that these walls to an area mean and highly
correlated.
And then one key point was to go on five point nine is, again, highly correlated.
So it has rejected so columns for us so we can directly to these one of these columns.
So when we when it is giving and we don't mean an area vorst, then we can remove eatables from this
particular data.
So that is how we can use this particular report and the other details, again, was the same way so
we can again decide what we need to do, what values we can use for improving those values, and if
there are any hihi values and then how we need to take care of them.
So all those details are provided by the that's provided to us.
Now, for though we have this is the data.
Again, and what we are doing is we are just getting the predictable values.
I'm from the predicted values of just getting the X values and the predictable, so I am slicing this
data from for all the rules.
And from the second indexed column to the last column, this means that it will ignore Zettl, ignore
one, and it will begin from the mean column and go up.
Fractal dimension WUST, it will ignore this minus one or two, it goes to one less than this one.
And then I have decided what V is here.
My V value is the diagnosis value.
So I have a sign that the D if I lock all the doors and only the first column for the next column,
which is a diagnosis called.
And this is the head of the data.
Now, based on this, I have received the correlation matrix, this core function gives this particular
correlation matrix.
This is similar to this matrix which we have here.
So this matrix actually tells us what all columns are kind of related to each other and the columns
which are highly related to each other.
We will be removing them because they will kind of increase the impact of their votes.
So we don't want to have a similar kind of viewpoint from two different columns because one column is
enough to provide its viewpoint.
So we will keep only one of the column for one type of relationship.
So this is why we are just creating this particular function, this particular function will find the
uncorrelated features from all the features which we have.
And based on that, it will on the columns, which we need to keep.
So what this does is it basically keeps the correlation value, so it creates a correlation matrix and
based on the correlation matrix, it shakes each and every value in the Polish relation matrix.
So this is the correlation matrix which has been generated.
So it has a lot of value is negative and positive.
All the values will be ranging from minus one to plus one.
The values, which are two minus one and the values which are nearly two plus one, are highly correlated
and the values which are near to zero are either not for on very least.
So we want to remove those particular columns, which have a very high correlation.
So that is why we will be removing the columns which have correlation, more than zero point nine.
So that is why we are giving the value to be zero point nine, so which is the reason why we are checking
the value of the correlation.
And if the correlation value is above zero point nine, then we are removing it.
Otherwise we are keeping it and we are spending it to the keep list.
And then this list actually provides us the list of all the columns which we need to keep.
So we have selected these many columns which we should keep.
Now, similarly, we have another matter, which is radiation variance, inflation factor, which is
a technique to estimate the severity of multiple linearity among the independent labels so it will find
out different variables in some.
Similarly, just the way we are doing this, just the way we are finding variables which we need to
remove, VIFF also helps us find those variables which we need to remove.
So what we are doing is we are again keeping the output values diagnosis.
And all of those values as the predictors.
And he'll be calculating the variation variance inflation factor using the ladin's inflation factor
method, which we have imported from the states model that starts outplaying winds of from the library.
And we will just push in the predictable values.
And the evalu value is just each and every column which we are taking it upon.
And we are getting the all the features which we want to have in this.
So we are kind of calculating the fact that for all the columns which are present, so when we print
this, we get all the features and their respective variation, variance, inflation factor.
So this factor should be a lesson then.
This is what is of great value.
So the value of value should be less than 10.
So that is what we are doing.
We have given the value to be then we are given the value to be then.
So based on that, we can find out what features we need to keep.
So here is another method implementation which you can likely use.
So I've just given the predictors inside this and the threshold value Usdin and based on the threshold
value, it is again calculating the variance inflation factor using the same library and it is just
removing the column name from the entire column list.
By checking if the value is greater than the threshold value, I'm giving us the.
Final details of what we need to keep and what we need to remove.
So this is the final detail from which I have received on this day.
The frame has the seven columns which I should keep from this entire dataset of thirty three columns.
Now, these are a few methods how we can actually select features and this is what we should learn.
Now, there are a few more methods lately.
Your feature selection using Glassell, which will we will be launching later when you will be learning
linear regression.
And again, there is a previous feature selection method which is using random forest.
So this is something that we will be learning.
Then we will learn about random forest.
So till then you can use these three methods to find out what all the columns you should keep and what
columns you should remove.