I am from biology and very new to python and ML, the laboratory has an ML blackbox model that outputs a sequence similar to this:
Predictions =
[1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,1,0,1,0,1,0,1,1,1,1,1,0,0,0,1,1,1,1,1,1,0]
each value represents a predicted time interval of 0.25 s. 1 means High.
0 means Not High.
How to convert these forecasts to [start, stop, label]?
so longer sequences are grouped in the example, the first 10 represent from 0 to 10 * .25 s, so the first range and label will be
[[0.0,2,5, high]
there are 13 zeros nearby ===> start = (2.5), stop = 13 * .25 +2.5, label = Not high
Thus,
[2.5, 5.75, Not-High]
so the final list will look like a list of lists / ranges with unique non-overlapping intervals along with a type label:
[[0.0,2.5, High],
[2.5, 5.75, Not-High],
[5.75,6.50, High] ..
What I tried:
1. Count the number of values in the forecasts
2. Create two ranges: one starts at zero and the other starts at 0.25. 3. combine these two lists into tuples
import numpy as np
len_pred = len(Predictions)
range_1 = np.arange(0,len_pred,0.25)
range_2 = np.arange(0.25,len_pred,0.25)
new_range = zip(range_1,range_2)
Here I can get ranges, but not enough shortcuts.
It seems to be a simple problem, but I'm running in circles.
Please inform. Thank you