In this situation, we would learn about Fondas and we will learn how we can work with him, so we would
implement what we have learned to critical detail now and what we have learned in pieces in Fondas.
So let us begin with that.
So first of all, we'll import numbers and find us after importing Memphian Fondas.
I'm just creating a new Dufrene with each physical safety I.D. rating, violence and children as columns
and these other details.
Now you can see that the age has values which are numeric in nature and it has strong values as defined.
And thirty four, which is again, no, but the data is strong and apart from that that is of the string
which is missing, which is present in each.
Then we have FICO range, which is entirely in a string form but is created out of numbers and no hyphen.
Apart from that, we have cities.
Mea.
Rioting and violent violence also contains not a number.
And children, Hasle range from zero to five.
And we have created 50 such rules, so I just run this and create a data frame using the dictionary
for my annual printing.
The head of the data frame, you can see we have these particular values and you can see in each column
we are not able to find any missing values as of now.
So let me just extend this a little bit and see if these 15.
So when I see 15 rows, yes, there are missing values and rule 11 and rule index 40 and there is an
order, no value and balance.
In Rule nine, so these are a few values which we will need to keep in consideration and try to modify
and try to in.
Now, the next step, which we have is I can take the data types, so when I see my detailed or Dee
Daibes, so I will be getting the data out of the columns which I have or the features or attributes
that I have.
Now, what are these other groups?
It is Aidy now Ibbs and Dijo, which is perfectly fine.
Age is object, which means that each is a string but each has to be a numeric because each is a number.
Right.
And here all these values are numbers.
So we have to convert each into a number.
That is the first point which we got from the second point is FICO.
FICO is a numeric type.
It is a data string.
But if the string because there is a range, there is a hyphen in between and there are two numbers
in here.
Now, we cannot really apply any mathematical operation on a string and that to having two numbers together.
So if you want to apply a mathematical operation, we need to have the hundred separate and one for
three separate so that I can either multiply with some number or divided with some number or do any
mathematical operation on top of it.
So the next task which I have in hand is.
To split these, so I want to have one hundred and one fifty in two different columns, or if I don't
create two different columns out of what I can do is I can take the mean of the physical value and create
a new column with only the mean value.
Because you see the range for all of these are 50, 150, minus hundred is fifty three hundred minus
two fifty fifty to fifty minus two hundred and fifty.
So all the differences between these values is 50.
So the range is fixed.
So what we can do is we can have a mean value and create a column which is just for me I'm in gives.
We don't want coming.
We can create two columns as we come in and go, Max.
So this is completely our choice, how we want to modify this particular column.
The next column is City Now, city is a string of values, is having strong values, so it is a categorical
column.
Now, what we have known for that to the column is that we will be creating dummies out of this.
That is, we will be creating one encoding, which is basically we will be creating a zero one zero
one nothing.
So we will have a column name Chinni and below zero or one values.
Based on that, there is a value present or not.
So we can work my way into another column on that column again, we'll have zero and one values depending
on if the value is Mumbai for that particular.
So each role will be converted into instead of a one city column.
It will be converted into four columns with each of the values of Jenay Daily Woombye and.
So we'll see how we do that next is having the reading column, this reading column will have again,
excellent vibe, excellent, but I think good values.
So these values.
Have.
US order in prison.
So there is an order present in these values, so these are ordinary values.
So ratings because it is the ordinary column or the new variable.
So we will convert this froma string type to one number nine.
We will give specific numbers to good, pathetic, excellent buy based on the sequence which is present
so we can give BIID as one, then pathetic as zero.
We can give good to let us see two and then excellent two three with three being the best rating and
zero being the most reaping now.
Next thing is balance, which is a floating coin.
So this is fine.
So balance has a floating point value, so it does not need to be converted into a numeric form.
Similarly, children is again in digital form, so it does not have to be converted into a numeric form,
which is already the numerical.
Now, as we look at these values now, age has these missing values and balance also has these not a
number of values, which means that we will have to imbue these values here.
So what we do is for these data types, once we have checked this, we will start modifying these values
one by one.
So here, if you see for my data age, what I am doing here is I am imputing the values.
I am just converting these values into a numeric form.
Now, how do I do it?
I do it with the user function to numeric.
So there's two numeric function, basically convert this.
A mixture of strings and numeric type in a B or numeric data and converting that, let us see if I just
simply do it this way, I just remove this.
It is not good cause because we don't know what that is as of now.
So once I run this, what happens is you can see that it gives me an error that unable to string missing
and position.
So I position 11.
It found a string which is missing and it is not able to understand what number should it please instead
of the string missing.
So it is not able to convert it properly.
So to resolve this issue, we basically have this error cause what it does is whenever it finds error,
it will convert that into not a number.
So I'll just run this for you, so when I run this, it has converted these values into Northern No,
you can see at 11 they have an odd number.
At 14, they have the number.
And if you will, check the data type again.
So let me run this one again.
So if you see the database back in the day that I would have changed to number.
Let me do this again, so here you see the leadership has changed to a floating point, so we have resolved
this particular issue.
Now, next, what we can see here is we have we can perform different operations like the new column,
or we can generate columns using the existing columns.
So here what I'm doing is I'm creating a column named Constant Variable.
I'm giving the value one hundred and say this.
So I'll run this.
And when I run this, you can see the data.
So I have created a constant variable which has value.
Hundert, how we create this is I just give the variable name, the column name in the races which I
want to create and the value in front of it.
So it has created this constant variable with value.
Next, I give a new column name, which is violence.
Log on.
The formula for it is and we don't look, I'm just applying the mathematical function log to the violence
value so it picks out the violence value.
And big a logo and puts it in the violence column.
Now, another thing is wherever the value of the violence would be, not a number, the value of violence
also comes out.
Do we know the number?
So once we are doing such operations, so what we will have to do is if we are imputing the values to
the violence column, we will also have to invoke new values to the violence column or what we can do
is be reinforced if we import the values in the violence column and then generate the violence column
so that it will automatically get the values from the violence column.
Now, the next thing is maybe the age children ratio now here what we are simply doing is we are getting
the age data and the children data and we're just dividing the data by the children data so that we
could get the ratio of now.
This is, again, the same thing, so because it has a number here.
So I know the number has been generated, so these are a few things which we need to handle accordingly.
Now we can do as many complex calculations, we want to create new columns and wherever we have missing
values, we will have to imbue those values.
Now, how we will impose those values will look at that little.
Here we have another column maybe that each now we will check if there is any value in this each column.
Now, as we already know, there are a lot of northern values in this particular each column.
So when we do some of these so I'll just run this so you can see whatever the value was, not that we
are getting a true.
And when they run up some more food, so it will give me some of those values.
So in total there are five nonsuch values.
So what we can do is we need to impute values that we need to fill these places so that whenever we
are performing any mathematical operation or whenever we are creating a model on top of it, it does
not have any values because in case they would be null value, then it would not be able to process
that to train our models.
So whenever we are training on to make sure that no column has any knowledge, values or any missing
values.
So what we do here is.
For my data, not location, so I'm filtering out the locations in my my data data frame and what am
I?
So I'm filtering my B that H.
So I'm filtering in the my data age column and what am I taking, I am checking wherever it is.
So this is basically filtering out the rules, maybe the.
So this is checking their my data, each column has a value.
It is just filtering out those five rows for me and.
It is taking out the each column out of it, so we are simply getting these values.
So let me run only this much piece of quote.
So here you can see we have figured out only the values, which are not the number in the each column.
So now what we are doing is we are simply pushing in my data each, not me.
So we are taking the mean of the mighty that each column and we are pushing it inside these five rows
of data.
Similarly, what I'm doing here is I'm taking the mighty the eight children ratio and I'm updating it
with the updated my data age and my little children.
So now there will not be any null values which would have been imputed earlier because of the knowledge
values.
So when I ran this and then done this again.
So now you can see there is no null value present in this particular column.
And when I run my data again, so you can see that the values which were not that is the 11th rule.
I'm the 14.
True, they have been computed with the mean of the each column I'm the same has been updated in the
children.
Rachel.
Now, the next thing what we can do is so here we have the reading school.
So now reading was or the news column.
So what did we decide?
We will give some reading to the ordinary values.
So instead of creating the values, what we do for all the variables is that we are pushing different
values to the goal itself.
So what I'm doing here is in the pathetic column, I'm pushing it minus one in the bag column I'm pushing
in Zettl in the good or excellent column we are pushing in the one volume so that the value for reading
is pathetic.
It will be replaced by one.
Whenever it is five, it will be replaced by zero.
Wherever it is good or excellent, it will be replaced by one.
So now what I do here is.
I check my little reading school.
This is a new column which I'm creating my writing school and I'm checking and beyond with this is a
new format for you and we don't where it is checking a particular location.
So where they're checking it is checking into my data.
Reading it is checking values in the middle eating.
Now, what is it checking?
It is checking that the value inside my eating is in.
If the value in the military thing is a part of this particular list, if any of these values is a part
of good or excellent, then or one otherwise make a.
So wherever the valley would be good or excellent, it would be changed to one and all of the values
would be converted.
Now see, whatever the value is good or excellent it has been converted to, one would just suffice.
Now, the other situation was the buyer has to be converted to zero, which is also fine.
That also has been done by putting Zettl in the other condition.
Now, the only thing that we need to make sure is that whatever the value is for Turkey, that has to
be replaced by minus one.
So what we do is in my location, my be eating whatever the value is, but typic.
We are opening the values for ratings, so we are getting the values for ratings.
So what we do is, again, we will run only this much piece of gold.
So let's run this first and we'll run this piece of code so you can see for filtered out breathing values,
that's what I do.
Because of this particular situation, the current values for my rating has been converted to zero.
Now, what we do is we will simply open the ratings for value and replace it by minus one.
And when we open this.
Now, you can see the values have been updated now in the trading volume, we have these values and
for those respective ratings, gold has been updated.
Now, we could have done this in several other ways, but we just wanted to introduce to you now let
me get my head again.
Now, in the state of Maine, we have corrected the each column.
The ratings have been updated, the eight show has been updated based on the new age.
Now, the next thing which we can work on is the equal value here.
The fecal value has a string and each string has numbers with a hyphen improvement.
So what we can do is we can split these values now to split a string, we have a split.
So let's try to use that mindset of equal split with hyphen as the split.
So when we run this big legacy, this object has no attribute split, which means that this cannot split
because it is considering this as a CBDs object.
So we need to focus on what this industry and then do the split.
So here they are, converting it into a string first and then performing the split on top of it.
So once we get a list of the numbers.
And now these two lists would have to be converted into data frames, so what we can do is we have expand
method present in place, which allows us to convert this these two lists into a complete form.
So what we can do is if you convert it into a data offering form.
So let me switch this and expand this so you can see that a new data frame has been created with the
forced index.
Has the value from the list the most value from the list, and the second one has the second value from
the list.
Now, the next thing what we can do is here we have got the data frame so we can finally get the Dufrene
convert this into a floor fight because this is still a string like it has been split into two different
values, but this value is still a string.
So we have to convert this into a number, into a plot point and then use it for the.
So what we do here is we get the mighty road vehicle then converted into a string after converting it
into a string.
We split it on the basis of the hyphen and we expand this so that it can words into our data frame of
the string as it is for the string.
So we have to convert it into a floating point.
So we are doing well as they float on top of it.
I'm then getting it into the gate, so this is my new data frame, which I have read.
So let me add on this, so let me bring for you so let me get keynoted.
So she has these two values now what I'm doing is I'm simply creating a new column, if one F2, you
can create one vehicle to vehicle, main vehicle, Max, anything like that.
I simply get the values of key index zero and gain one into it.
So after that, I will simply delete the column because I have selected the vehicle for Elamine and
I don't need this particular column now, I don't want this kind of values.
I can just use the new vehicle values which I have created.
So I'm just deleting it using beneath my dad or vehicle.
I can use different methods for deletion, like throw up my little vehicle so that we can save my data,
not my date of drop, so we can do something like that.
So now let me bring my data.
So now we don't have the full volume and it has been removed.
Now there is a dating column which also needs to be removed.
Apart from that, we have this city in which we need to take care of.
So how do we do that?
We can use the antidote barometer, which we simply need where we want to check the value.
So we are checking my data city values and we are checking if my editors be in the movie.
So whatever might be the equivalent to city might be the city's equivalent of Mumbai.
We are putting one and there it is not equal to my rate as a vehicle.
Then we are putting zero there.
So that will make the City Mumbai column where the values will be one or zero based on if the value
is Mumbai in the city column.
So I just ran this.
Similarly, I have another condition where I'm creating the new column city today and I'm checking my
status to be is equivalent to Jinney.
So wherever this condition will be true, the value will be up in deejayed.
I will be the value will be of not zero and wherever the value will be.
So basically, it will give a boolean exaggerated, will have either true or false value.
They've done this for you.
So when we are checking this, it is giving a true and false value and what we are doing is we are doing
the stip in.
So when the truth will be converted to it, it will be converted to one and then it will all be false,
will be converted to and it will be converted to zero.
So automatically we will get the same thing which we are achieving from this.
So it will give just the same thing.
So let me run this again.
And now we are simply checking another condition in gymnasia global indigency.
So we are just doing the same thing.
Now, our next thing is my little Golgotha.
So we are creating another column called Golgotha and then we are using an order.
So let me just run this and we will need the my column and we see the head.
So now what has happened is the city column has been removed and there the city column value was changing.
It has one here where the city column value was Malai.
It will have one death whenever the city column value will be equal, that it will have one death.
And when the city column value was Delli, it will be all zeros, which is signified by the fourth one.
Now, the next thing is of the gun.
Another thing is we can believe the city, the rating column.
Now here what we are doing is we are getting another dummies for the reading columns.
All we are doing is we are simply doing the deed on dummies and we are taking my data reading and we
are doing a drop forced.
Through, which means that I want to remove one of the values I'm going through, you fix reading,
I'm getting up and you fix them, so I'll just run this.
So here what it has done is we have three, four ratings and one was good, one was bad, one was pathetic.
One was excellent.
So when I used drop first, so it dropped the vibrating column because as we have discussed, it will
mean like if all three volumes of these are Zeitels, that will mean that we are pointing towards bag.
So we don't really need to have the bad column here.
And the prefix simply means that I want this rating as a prefix here.
So in case I don't want that.
And I'll run this again so we will get the bad.
So it has just dropped the first column, so I'll just put it back again and you can see it has been
removed.
So then after this, we once we have created the dummy columns, we can concatenate the dummy columns
and we can remove the ratings.
And here is their data, which we have.
So this is how we can work, whether we can create these rating columns also.
And also we can create this rating scores.
Or the preferred method is to create a rating score, which will create one column only and not multiple
columns for an ordinary data.
This is just to show how Dumi is used, but we will be using this particular method for any ordinal
variable and we will be creating dummies for any categorical.
So this is for this particular session, in the next session, we will learn about the election and
the four steps which we follow while we are creating the features and why we are selecting the features.