In this video, we will learn how to handle these categorical variables by creating dummy variables.
As told in Italy later, whenever we have categorical variables, we need to transform them into dummy
variables containing numerical values.
Since our regression model cannot handle non numerical values.
So we have these three categorical variables, airport, autobody and buster, which contain no numerical
values, and we will look at their categories and determine the damage to be created.
So I have the filtering options here.
If you want to apply filtering options, you have to select the top row and go to data menu and click
on this filter option.
Ed, if I open the wildling options for the airport variable, you can see that it contains two values.
Yes and no.
If I say yes, that is a ungentle.
The number of years in the observations can be seen by selecting all the cases and you can see the count
below it is 279.
So out of 506 observations, I have 279.
Yes.
So there are two categories in the airport.
But even as total energy related, we need and minus one, the many variables and is two.
So we need only one dummy variable.
So we'll create a new column.
Will Namik Airport under serious?
It will contain one whenever the value of a variable is yes, and it will contain zero whenever the
value of a variable is not.
So here we need to use it function.
We will see if the value in the corresponding sale is yes.
In double quotation marks, yes.
If this is true, we want it to be won.
If this is false, we want it to be zero.
You can see we get one when Deerwood values.
Yes.
If I drag it to all the other cells below the cell, I'm getting Landreaux wherever there is no, I'm
getting a zero.
Whatever there is.
Yes, I'm getting one.
So the dummy variable for airport categorical variable is ready before deleting the airport variable,
we need to change this formula to values.
So we will select all details, copy them.
Then we will right click and paste as values.
Now it has value instead of the formula.
Now I can delete this column.
So we have airport dummy variable instead of the airport categorical variable, the next categorical
variable is autobody.
This variable contains.
Four categories, one is like one is lake and river, one is none.
And the last one is River.
Since it has four categories, we need four minus one.
That is three dummy variables.
So we will keep three dummy variables, one with name water, body lake, one with name, water, whatever.
And the last one with the name Water, Body, Lake and River.
So we need to insert three different columns.
In the first column, I'll take waterboarding Underscore Lake.
This will have value one if the value in the corresponding water body variable is lake, otherwise it
will have value zero.
So will rate is equal to if.
This still has Value Lake,
then it would be one altitude video.
Extended to other cells in the column by devils living on the bottom right corner of the cell.
Now, in the next column, will they waterboarded over?
Here, if the value is reversed, then it will be won, otherwise it will be zero.
You can see that whenever the values revert to water, what it will be very will contain the value of
one lasting water body, lake and river.
Well.
In this variable.
If Disvalue is lake and river.
Then it should be one other way.
It would be little.
Double click on the bottom right corner to extend it to other states so we have three variables to represent
this one categorical variable since it has four categories.
Now we will select the values in all these three columns.
Copy them, paste them as values.
And we can delete the water body very well not.
The last categorical variable is bus terminal.
It has only one category, which is, yes, if a categorical variable has only one category, it is
not really a variable.
It can be treated as a constant and we do not need any dummy variable to represent this variable since
and then minus one and is equal to one, then the count of the variable comes to zero.
So we do not need this variable at all.
We will straightaway delete this variable.
So with this, our dataset has no blank values, it has no outliers, and all the categorical variables
are converted to numerical values.
With this data set, we are ready to run our analysis.