PadhaiTime Logo
Padhai Time

Log Transformations

As we have seen, Normalization and Standardization techniques are able to bring the different scale attributes to a common scale, but if the distribution is skewed, then it remains skewed after the scaling process. Log transformations can help in making a skewed distribution to a normal distribution or a highly skewed distribution to less skewed.


Few real world examples where Log transformations are done:


- Measuring Earthquake

- Measuring Sound


Now let us look at our last example where the attribute “Fare” is highly right skewed. 



import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
data['new_fare'] = data['Fare'].apply(lambda r: np.log(r))   # Apply log transformation





As we can see that our original data was highly skewed and after transformation skewness is reduced. Now the transformed values are more visible.


Point to Remember:

  • If you have negative or value as 0 in your distribution, then log transformation can’t be used.
  • Log can only take positive values as input
  • Log(base 10) and Log(base e), both can be used for log transformations. You should not see any accuracy related issues.

Bengaluru, India
  • We collect cookies and may share with 3rd party vendors for analytics, advertising and to enhance your experience. You can read more about our cookie policy by clicking on the 'Learn More' Button. By Clicking 'Accept', you agree to use our cookie technology.
    Our Privacy policy can be found by clicking here