April 2018
Beginner to intermediate
282 pages
6h 52m
English
Trimming is the same as winsorizing, except the tail values are just cropped out.
The trimboth method in the stats library slices off the dataset from both ends of the data. The final_data and the limit of 0.1 are passed as parameters to the function to trim 10% of data from both ends:
### Trimming Outliers ###from scipy import statstrimmed_data = stats.trimboth(final_data, 0.1)#Check trimmed dataplt.cla()plt.figure(1)plt.title("Trimmed Dummy Data set")plt.scatter(range(len(trimmed_data)),trimmed_data,c='b')
We can observe from the following resultant plot that the extreme values are clipped and do not exist in the dataset anymore: