Welcome back.
Let's continue with data preprocessing.
Here we need to convert the categorical origin column into one hot encoding, which is a crucial step
for preparing categorical data for ML models.
Don't worry, we're going to clarify everything in the next couple of minutes.
PD dot get dummies here.
We need to pass the parameters x columns and the prefix.
Prefix is origin columns origin and x is the data.
One hot encoding converts categorical variables into a binary zero or ones format that ML algorithm
can understand.
Here we have, for example, origin one.
If we go up with our data, we have origin one means American origin two.
European Origin three.
Um, Japanese.
So if we look at the data again, you see this column number one American, three Japanese and two European.
Okay.
So if we have, uh, like this data, we need to inform the ML algorithm and make ML understand that
one represent American origin.
Two European, three Japanese.
We need to transform this into something that ML can understand.
So before converting we have data like this one, two and three for the origin.
And after converting after one hot encoding we're going to create three columns origin one, origin
two and origin three.
And every um and one represents that it is true.
Zero represents that it is false.
Let me show you guys.
So here print features after one hot encoding print x dot head.
Let me get the first cells run again.
And here we go.
We have cylinders displacement horsepower weight acceleration model year.
Those are the same.
But the newly created columns are origin one, origin two and origin three.
Origin one means that it is American.
Origin two means that it is European origin three represents Japanese origin.
Okay.
In this way we can convert this into something that it is readable by ML algorithms.