I've written some code to find how close the diffs of two time series are to each other and do this by finding the distance from the expected difference locations from the nearest actual change and assigning a score based on how far off it is.
In that code I have something that looks like this:
nearest_change = np.abs(actual_changes[actual_changes == change].index - time).min()
minutes_off = nearest_change.seconds/60
if minutes_off < 15:
sum += 1
elif minutes_off < 30:
sum += .8
elif minutes_off < 45:
sum += .6
elif minutes_off < 60:
sum += .4
elif minutes_off < 65:
sum += .2
return sum / count
Is there a more pythonic and concise way to achieve this sort of scoring?
Aucun commentaire:
Enregistrer un commentaire