Skip to content

Commit

Permalink
city outlier changed interval
Browse files Browse the repository at this point in the history
  • Loading branch information
Nik Sauer committed Feb 20, 2025
1 parent a06e118 commit 13cc490
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
2 changes: 1 addition & 1 deletion code/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class Dimension():
}

# outlider factor
IQR_FACTOR = 3
ALPHA = 0.1

_filter_thresholds = {
PM2_5: (0, 999)
Expand Down
7 changes: 2 additions & 5 deletions code/routers/city.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,9 @@ async def get_average_measurements_by_city(
data = []
for dim, val_list, val_count, s_cnt in q.all():
a = np.array(val_list)
q1 = np.percentile(a, 25)
q3 = np.percentile(a, 75)
iqr = (q3 - q1)

l = q1 - iqr * Dimension.IQR_FACTOR
r = q3 + iqr * Dimension.IQR_FACTOR
l = np.percentile(a, 100 * (Dimension.ALPHA / 2))
r = np.percentile(a, 100 * (1 - (Dimension.ALPHA / 2)))

b = a[(a >= l) & (a <= r)]

Expand Down

0 comments on commit 13cc490

Please sign in to comment.