Commit 73b3fa33 authored by panos's avatar panos

Bugs fixed in the DetectOuliers object

parent b7642581
......@@ -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
def DeleteOutliers(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=[]
for value in mylist:
if not ((value<LOF or value>UOF) or (value<LIF or value>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
if not ((float(value)<float(LOF) or float(value)>float(UOF)) or (float(value)<float(LIF) or float(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
return listx
def DeleteExtremeOutliers(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=[]
for value in mylist:
if not (value<LOF or value>UOF): #If the value is beyond the outer fence ([LOF,UOF]) on either side (extreme outlier) doesn't pass the control and deleted
if not (float(value)<float(LOF) or float(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
listx.append(value)
i+=1
return listx
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment