#Two different approaches to handle the outliers are included in this object,
#the first one delete both the mild and extreme outliers while the second approach delete only the extreme outliers in the given data set
defDeleteOutliers(self,mylist):#Delete the ouliers (both mild and extreme) in a given data set
A=BasicStatisticalMeasures()#Call the BasicStatisticalMeasures to calculate the quantiles and interquartile range
Q1=A.quantile(mylist)[1]
Q3=A.quantile(mylist)[3]
IQ=A.IQR(mylist)
LIF=Q1-1.5*IQ#Calculate the lower inner fence
UIF=Q3+1.5*IQ#Calculate the upper inner fence
LOF=Q1-3*IQ#Calculate the lower outer fence
UOF=Q3+3*IQ#Calculate the upper outer fence
i=0
listx=[]
forvalueinmylist:
ifnot((value<LOForvalue>UOF)or(value<LIForvalue>UIF)):#If the value is beyond the inner fence ([LIF,UIF]) on either side (mild outlier) or beyond the outer fence ([LOF,UOF]) on either side (extreme outlier) doesn't pass the control and deleted
listx.append(value)
i+=1
returnlistx
defDeleteExtremeOutliers(self,mylist):#Delete only the extreme ouliers in a given data set
A=BasicStatisticalMeasures()
Q1=A.quantile(mylist)[1]
Q3=A.quantile(mylist)[3]
IQ=A.IQR(mylist)
LOF=Q1-3*IQ
UOF=Q3+3*IQ
i=0
listx=[]
forvalueinmylist:
ifnot(value<LOForvalue>UOF):#If the value is beyond the outer fence ([LOF,UOF]) on either side (extreme outlier) doesn't pass the control and deleted