Feature Scaling

Understanding Feature Scaling is very simple.

We will look at the sample data set below. The 'Buy' column is the dependent variable while others are independent variables. If we consider Age and Salary columns they have two different scales. Age has 25-40 scale while Salary has 58000-78000 scale.
In ML we are creating mathematical models. If we use this kind of unscaled data to build ML models then it may end up with bad models. For example, the Euclidean distance is used in most ML model building. Just think that we apply Euclidean distance to Age and Salary when age is 35. The value is √(35^2 + 62000^2) = √(1225 + 3844000000). We can see that the effect of 35 is negligible with compare to 62000. On the other hand we can say that there is no effect of Age variable in above type of calculations although it should be. The reason to this issue is the different scales of Age and Salary. To overcome this problem we have to take variables into a same scale. The process of this scaling is called as Feature Scaling in ML.

USA     UK   Canada   Age       Salary     Buy
1             0          0          35        $62,000     Yes
0             1          0          25        $58,000      No
0             0          1          40        $69,000      No
1             0          0          40        $78,000     Yes
0             1          0          30        $64,000      No
0             0          1          30        $61,000     Yes

Comments

Popular posts from this blog

Importing libraries in Python

Taking care of missing data in a data set