@@ -29,10 +29,9 @@ class HandleOutliers(BasicStatisticalMeasures):
#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)
Q1=self.quantile(mylist)[1]
Q3=self.quantile(mylist)[3]
IQ=self.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
...
...
@@ -40,22 +39,21 @@ class HandleOutliers(BasicStatisticalMeasures):
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
ifnot((float(value)<float(LOF)orfloat(value)>float(UOF))or(float(value)<float(LIF)orfloat(value)>float(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)
Q1=self.quantile(mylist)[1]
Q3=self.quantile(mylist)[3]
IQ=self.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
ifnot(float(value)<float(LOF)orfloat(value)>float(UOF)):#If the value is beyond the outer fence ([LOF,UOF]) on either side (extreme outlier) doesn't pass the control and deleted