I have a 2D numpy array. Each row contains time-sampled data which must be matched to several different possible criteria.
For each row, several different criteria must be applied. Each row is data from a system, and each criteria represents a different situation that could be detected. A criteria condition is detected if select columns in the row are within a certain interval (greater than and less than certain values).
Is there a way to do this very fast and effectively in numpy? I have been looking around and didn't really find a way, although I am new to numpy.
I was thinking of a hash mechanism, such as storing some hash for each row and seeing if the criteria's hash matches that row's hash. However, the hash mechanism would only work with fixed values, and not ranges of values. Therefore, this would not be really applicable.
Example data:
import numpy as np
myData = np.array([[7.241, 7.123, 9.0, 1.2, 1.0, 1.5, 67.14, 162.32], [8.123, 10.4, 7.68, 1.6,0.7, 2.3, 21.2, 175.2]])
Example conditions:
Criteria #1:
condition 1 : column 1 must be greater than 6 and less than 7
condition 2 : column 4 must be greater than 0 and less than 2
condition 3 : column 6 must be greater than 10 and less than 50
(conditions are 'and' operation, so all conditions must be met for criteria to be met or not)
Criteria #2:
condition 1 : column 3 must be greater than 10 and less than 22
condition 2 : column 4 must be greater than 9 and less than 15
I was thinking of whether numpy supports some sort of regexing so to speak in this regard. Are there any mechanisms or techniques in numpy that would facilitate this efficiently?
The above example is simple, but in actual application, the matrix would contain several hundreds of rows and there could be several tens of criteria to evaluate against each row.