I have a list predictions [0, 1, 0 , ....] and a list outcome [ 0, 0, 1, ...]. I want to create a list of all predictions where outcome is 1
I tried:
filtered_list = [predictions[i] for i in predictions if outcome[i]==1]
Unfortunately that resulted in an empty list.
What am I doing wrong? EDIT: I think I fixed it - not sure, as I have not been able to audit the result
filtered_list = [i for i in predictions if outcome[i]==1]
predictionsis a list of 0s and 1s, you are only looking atoutcome[0]andoutcome[1], not the outcome of a prediction.