VOOZH about

URL: https://www.geeksforgeeks.org/data-science/winsorization/

⇱ Winsorization - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Winsorization

Last Updated : 30 May, 2021

Winsorization is the process of replacing the extreme values of statistical data in order to limit the effect of the outliers on the calculations or the results obtained by using that data. The mean value calculated after such replacement of the extreme values is called winsorized mean.

 For example, 90% winsorization means the replacement of the top 5% and bottom 5% of the data. The top 5% of the data is replaced by the value of the data at the 95th percentile and the value of the bottom 5% of the data is replaced by the value of the data at the 5th percentile. 

Input:

  • A numeric array whose values at the upper end and the lower end are to be winsorized.
  • The first argument of the tuple is the percentage of values at the lower end which are to be winsorized.
  • The second argument of the tuple is the percentage of values at the upper end which are to be winsorized.

Output:

A numeric array whose values at the upper end and at the lower end are winsorized as defined by the user.

Example #1:

Let us see an example where outliers are present on both the upper end and the lower end of the data.

Output:

Output:

👁 Image

Now, we winsorize the array by 10% i.e. we winsorize 5% of the highest values and 5% of the lowest value of the array:

Output:

Output:

In this case, there is only a slight change in the mean value of the data.

Now, let us see an example where outliers are present only at one end of the data.

Output:

Output:

Output:

Output:

In this case, there is a significant difference in the mean value.

Comment

Explore