File tree Expand file tree Collapse file tree 2 files changed +9
-18
lines changed Expand file tree Collapse file tree 2 files changed +9
-18
lines changed Original file line number Diff line number Diff line change @@ -52,22 +52,13 @@ def iqr_detector(measures, iqr_proportion=1.5):
52
52
# * You'll likely need np.logical_or
53
53
# https://textbook.nipraxis.org/numpy_logical.html
54
54
# +++your code here+++
55
-
55
+ # Calculate the quartiles of the data
56
56
Q1 = np .percentile (measures , 25 , interpolation = "midpoint" )
57
57
Q2 = np .percentile (measures , 50 , interpolation = "midpoint" )
58
58
Q3 = np .percentile (measures , 75 , interpolation = "midpoint" )
59
+ # Calculate the interquartile range
59
60
IQR = Q3 - Q1
60
-
61
- outlier = []
62
-
63
- for i in range (len (measures )):
64
- if (measures [i ] > (Q3 + IQR * iqr_proportion )) | (
65
- measures [i ] < (Q1 - IQR * iqr_proportion )
66
- ):
61
+ # Calculate the outliers
62
+ outliers = np .logical_or (measures > (Q3 + IQR * iqr_proportion ), measures < (Q1 - IQR * iqr_proportion ))
63
+ return outliers
67
64
68
- outlier .append (True )
69
- else :
70
- outlier .append (False )
71
-
72
- #print(outlier)
73
- return np .array (outlier )
Original file line number Diff line number Diff line change 19
19
# Hint: sys.path
20
20
# Hint: see the solutions if you are stuck.
21
21
# +++your code here+++
22
+ findoutlie_dir = MY_DIR .parent
23
+ print ("The directory containing detectors is {}" .format (str (findoutlie_dir )))
24
+ sys .path .append (str (findoutlie_dir ))
22
25
23
- #import sys
24
- #export PYTHONPATH=$PYTHONPATH:C:/Users/nauma/Documents/nipraxis-work/diagnostics-NME/findoutlie
25
- #sys.path.append('C:/Users/nauma/Documents/nipraxis-work/diagnostics-NME/findoutlie')
26
26
import numpy as np
27
27
28
28
# This import needs the directory containing the findoutlie directory
29
29
# on the Python path.
30
- from findoutlie . detectors import iqr_detector
30
+ from detectors import iqr_detector
31
31
32
32
33
33
def test_iqr_detector ():
You can’t perform that action at this time.
0 commit comments