great question. Here's my take on it:
# define upper (UL) and lower limits (LL): simulated based on chart
Y_UL = [40, 41, 42, 43, 42, 45]
Y_LL = [32, 33, 34, 35, 34, 38]
# get the measurements: simulated based on chart
my_Y = [35, 36, 35, 35, 35, 36]
# define lambda to encode 1/0 and limits as parameter for a list
my_lambda_onehot_UL = lambda X, UL_list, LL_list: [
# encode:
# `1` if within upper and lower limits (no touching)
# `0` if touching the limits and outside
1 if (UL_list[idx] > x and x > LL_list[idx]) else 0
# iterate the list including indexes
for idx, x in enumerate(X)
]
# run the lambda
print(my_lambda_onehot_UL(my_Y, Y_UL, Y_LL))
# [1, 1, 1, 0, 1, 0]
Output explanation:
- value #4,
35
is on the lower limit 35
- value #6,
36
is outside of (38;45)
# check if any point is outside using `numpy`
from numpy import mean as np__mean
np__mean(my_list_01)
# 0.6666666666666666
Having this allow one to quickly collect arrays of 1's and 0's which can then be reduce()'d using averaging, if average is 1 -> all points are within.
The key question remains regarding true values my_Y
, Y_UL
, and Y_LL
.
I wonder if this improves process in any way