All before going deeper into recession.
Let's have a quick recap of what we all have done in all our previous session.
So we have basically performed lots of people, lots of analysis on data to extract some meaningful
insights from data because we have to represent to our clients, to our stakeholders here.
These are exactly your insights from data.
And we have performed several techniques of speech and coding on our data.
So in this session, what we have to do, we have to basically deal with the outliers.
The very first statement for this particular session, we have to deal with the outlier as well as imputation
of the outliers if it is available on data.
So definitely outliers will be available in, you know, Matkal column.
So I'm going to check whether I have some outlier in my price column or not.
So the two main plots, the two main visuals that will be very handy for you whenever you have to deal
with the outliers are exactly your distribution approach and your box plot approach.
So what I am going to do, I'm just going to define a function over here.
Let's say its name is plot and what it will achieve.
The very first one, what data frame and the second one on what column you have to perform this operation.
And let's say the very first operation, I exactly need my distribution thought.
And here what I have to do, I just need a distribution of this D.F. of columns.
Similarly, I'm going to call this box plot and here as well.
I just need a box part of this one, let's say, on the very first axis, on the very first axis.
I just need distribution and on the second axis, I just need a box.
But so far, this what we can do.
We guys can create a subplot for this and we do say BLT Dawid subplots.
And here, if you will, press shift, plus that you will check what exactly the documentation, what
are the custom parameters that this function will see.
You will see a number of rows, number of columns.
So let's say I just need a matrix of to come over.
I can say here I have two rows and one column, so it will exactly return me one finger.
And inside that one finger, basically I have one axis.
Next year I'm going to say this is exactly my X1 and I have X two in my finger.
So what I have to do on this axis one, I'm going to say I have to represent my distribution and on
access to I have to represent my box plot.
That's it.
So if I'm going to execute it, I have to execute all the stuff.
And after that, what we have to do here.
Very first, I have to parse what exactly is the frame name and on what column I have to perform this
operation.
Just execute it and it will return this beautiful distribution plot as well as this beautiful box.
But you will see it here in this distribution.
You have some outliers because it is positively skewed distribution.
You will see it here similarly in this box, but you will see what our data points, what our data points
you will see over here.
These are exactly your outliers.
So let's say after having conversation with my domain expertise, he or she said, yeah, whatever data
point that is greater than forty thousand, that is definitely an outlier.
So what I am going to do, whatever data point I have greater than forty thousand.
I'm just going to replace it with median because whenever you have an outlier median plays a very handy
over there.
So for this, what I'm going to do, I'm going to use a very handy function of numbers and here I'm
going to say no matter where and if you will shift gears to the very first one, what exactly would
condition in and on the basis of condition we have to perform some operation.
So here I'm going to say my condition is exactly so.
I'm going to mention my condition.
So whatever my condition is on the basis of condition, it will take some action.
So my condition is exactly D.F. of price greater than equal to forty thousand.
So wherever this price is exactly greater than forty thousand in such case, I have to compute, I have
to replace it with median.
So I'm going to say data on the screen of price and on days I have to basically compute median of that.
So I'm just going to compute median and wherever this condition will not satisfy it means whatever my
price is exactly less than forty thousand.
So in such case, what we have to do, we have to simply escape it.
So wherever it is, less than forty thousand in such case I don't have.
To perform any operations on data.
So here I am going to say it on a train of crisis.
It means I have to make it as it was.
So what I'm going to do after it, I have to update this price as well.
So what I have to do, I have to restore it here.
This way I can restore it to just execute it.
And if let's see if I'm just going to copy this again and again, I'm going to paste to what, dear?
Now you'll see or hear your distribution data also gets changed.
And this box also gets change is still you have some outliers.
You will see.
But that's okay.
But because you will see here, you don't have far beyond our you don't have that much high outliers
as you have earlier.
So it means up to some greater extent your data is somehow already.
So just go ahead with our next problem statement in which we have to separate our independent features
as well as dependent feature.
So for this, what we going to do?
It means I'm just going to separate my data.
So in X variable, I'm going to contain my all the independent features and in variable I'm going to
consider all the dependent feature.
So for this, I'm going to say in this X, I'm going to say data on a train drop and what I have to
drop, I have to drop.
Simply pass it, because price isn't my dependent feature, because this is that feature that we have
to study.
So what I'm going to do, I, I have to exclude this teacher.
So using this drop and if I'm not going to mention my in-place parameter, so it means I don't have
a drop in this act.
So if on this X I'm going to call ahead, then you will see over here all of this stuff gets executed.
And in this X, you don't have a price column.
And let's say on this X, if I'm going to call, let's say, shape what exactly the shape of this.
So you will see it had just thirty four columns.
Add in this all the same in this region.
Data frame.
If I'm going to call shape of this, you will see this has thirty five features and this has thirty
four features because it doesn't add your price feature.
So basically in this variable I'm going to say I have to just access my price.
So I'm going to say just access this price.
And if you want to get some rough idea you can print it.
You will see in this variable, this is exactly the index.
And with respect to index, you have some price entries.
So that's all about the second profile of the second that you have.
And I think he's going to get the same.