All before going deep dive into this session, let's have a quick recap of what we have done in all
our sessions.
So doing lots of analysis, doing lots of techniques of feature engineering as well.
And we have found some meaningful insight as well.
And for machine learning aspect, what we have done, we have performed this correlation, doing feature
encoding techniques on our data and how to handle our as well.
What we have done in the previous session by just defining dysfunction in which we are seeing just apply
log on the data.
That's what we have done in our previous sessions in the session.
What we have to do this is exactly this assignment for this particular session in which I have to apply
techniques of feature importance on our data to select what are exactly my most important features to
build a machine learning model.
Because if you will observe here, you have plenty of features.
Look at that here.
You have tons of features.
So from this end number of features, you have to select some subset of features that are going to contribute
more to your machine learning model.
That's what exactly my feature important technique will do.
So first, let me check if I have any value in my data frame or not.
I'm just going to call this is null.
And let me just call to some to get a summation of all the missing values and you will figure out here
I have the single missing value so you can just drop it.
That's it.
So I'm going to say data frame don't drop any and just place in place equal to truth so that you can
obliterate every that just executed.
And if now what you have to do now, you need your independent feature as well as your dependent features.
So let me just define two variables as lie.
So why is exactly your dependent feature?
So I'm going to say data frame of is underscore cancel.
So this is exactly your dependent feature that you have to predict with respect to different number
of independent features.
So now how you have to consider your independent features.
So if let's say let me show you a thing.
So if I'm going to say that a frame got drop and here if I'm going to set this is underscore cancel
and if I'm not going to set any in place parameter, it means I'm not going to update the frame.
And if I'm going to that, you want to sell.
But before executing, you have to set one more parameter, which is exactly exis.
It means how you have to drop this column.
So if I'm going to execute it now, you will see here you have all your features except that this one,
it means this is your data frame or you can say this is that set that exactly your independent feature.
So I'm going to say let me just copy from here.
Let me just did it.
And in this X I have to just assigned it.
That's it.
Now just aggregate it.
Now you have to perform your future importance concept on your data for this.
You have to import some libraries that will definitely help you to do all these several task.
So for this, I'm going to say from this cyclone module, I have something which is exactly my linear
and it's called model.
And from this I have to import my algorithm, which is exactly my Lessel, which is exactly this one.
After what we have to do, let's say from this ascalon, I have something which is exactly my feature
and it's called selection to select your most important features.
This is exactly that some module that is going to help you a lot.
So from this module, you have to import something known as select and just step.
And here this is a class that is going to help you a lot to perform this feature importance concept.
So here what I have to do very first, I have to initialize this select from model.
And here what I have to do, I have to specify my this last regression model.
So here what I'm going to do, I'm just going to say initialize this.
And here I have two very first, Manchanda Slessor.
And if I will press schist crosstab over here, you will get all Erastus.
What exactly is the alphabet amedure and what is your fitness going to set all these custom parameters
here?
So the main parameter that you have to take care of it with is exactly this.
Elsah So what exactly this Alphie is.
So it is equivalent to your penalty parameter.
It means the bigger the value of the alpha, the less number of features will get selected.
Let's see.
I just need more number of features.
It means I have to set some low value of.
So here I'm going to say Alpha, let's say close to zero point zero zero five, let's say I'm going
to set this value from my own experience, or if you want to customize this value, you can just something
known as cross-validation.
But here I am going to set this threshold value from my own experience, working on different, different
project on different different domain.
So after it, what I have said, I have to set something known as my random parameter and assign its
value as zero after doing all this stuff.
What I have to do then I have to use this select from model, which is exactly inside my cyclotron.
And this tells how this will select the features whose coefficients are non-zero.
That's what that's what the select phone model will do.
So here I am going to say it's object, like I'm going to store it somewhere else.
Let's say feature on this code selection, underscore model.
Let's say this is exactly its object.
After it, I have to just execute it.
Now, what we have to do, we have to basically fit my data to its object.
So for this, I'm just going to say dot fit.
And here I have to mention this Y and X, so I'm going to say X, comma Y, you just execute this and
it will take a while and all the stuff in front of you, you will see your last model has been executed.
And these are all the custom parameters that you have defined and these are all the things that you
have done.
So if you want to check.
Yeah.
What are the columns that are selected by these select from model class.
So for this I'm just going to say feature on this selection model dot get on underscore support, which
is exactly this one, and just execute this.
You will see all your columns in the form of a list where you have values as central.
So whenever there is a false, it means that model or you can say that feature selection technique is
going to recommend.
This feature isn't contributing more to my machine learning model and true means here.
You have to consider this feature for your machine learning model.
So for this, let's say I have to visualize here which feature gets elected and which feature doesn't
get selected.
So let's say I have to create a data frame or let's say you want to print it.
Let's say whatever you want to have to print it, I have to print.
So let's say if I'm going to call my expert columns, these are my all the columns.
Let me store it somewhere else.
Let's say these are exactly my all the columns over here.
Now, what I have to do is I have to print something.
So I'm going to say let's say I have to print what I have to print.
I have to something like, say, my total features features.
Then I have to add something known as a placeholder.
So here I'm going to add my placeholder and this placeholder will receive value from my form and function.
So I'm going to say a dot format and after it, what I have to do, I'm going to say X dot shape.
And let's start with the number of column columns.
So just pass one over there and in a similar way what you guys can do.
Let me just copy this and let me just paste or did this time let's I have to print my select features.
I'm going to say it is nothing but let's say my selected features and here what I have to pass.
Let me just store it somewhere else.
Let's say selected features are nothing, but let's say I have to class basically this filter in my
column.
So here I'm going to say I have to pass this filter in my column that said, if I'm going to execute
it, you will get all your columns that have been selected from your select key model technique.
So here you are.
I have to do to store it somewhere else, I'm going to say selected on this score feature.
So just execute it now.
Here, what I have to do here, I am going to say I had to simply print it slant.
I'm going to say basically land of whatever list I have defined.
What and if I'm going to execute the salvator, you will see you have total features as trunked, but
your model selects all your 14 features.
So these are exactly your 14 features that you have to consider for the machine learning aspect.
So let me just print what are exactly those features.
So these are exactly all your features.
It means you just need this feature to build a machine learning model.
It means you have to consider those features as your independent features.
So let me update my X, which is exactly my independent data frame.
So I'm going to say if I'm going to pass this selected underscore feature in my X, so if I'm going
to execute it now, you will see here you have this fourteen column.
It mean this is.
Your independent features, so let me just assign it an X that sit, so now you're dependent on data
and independent data is almost ready.
And in all of your upcoming sessions, we are going to build our model and we are also going to check
what exactly the accuracy, how we can cross validate our model and all these things in a much more
depth.
So that's all about this session of the session.
Very much.
Thank you.
Have a nice day.
Keep learning.
Keep growing.
Keep practicing.