O/p is ==> ([100, 1000], []) but Sir as your code is not detect outliers Please help .. Got it Thanks Sir ....
Closed this issue · 0 comments
AMEERAZAM08 commented
**X=[1,2,3,4,5,6,10,100,1000]
q1,q3,lower,upper
def detect_out(data):
q1=np.percentile(X,25)
q3=np.percentile(X,75)
iqr=q3-q1
lower=q1-1.5*iqr
upper=q3+1.5*iqr
outlire=[]
for i in data:
if i>upper or i <lower:
outlire.append(i)
return outlire
outliers=[]
def detect_outliers(data):
threshold=3
mean = np.mean(data)
std =np.std(data)
for i in data:
z_score= (i - mean)/std
if np.abs(z_score) > threshold:
outliers.append(y)
return outliers
detect_out(X),detect_outliers(X)**