backend/sweettweet/services/utils.py
def glu_to_alarm(y_true, y_pred):
	'''
	Convert glucose levels to alarm.

	Alarm state is positive if glucose at time 
	t and t-1 is < 70 and >70 at time t-2.
	'''
	hypo_real = (y_true < 70).astype(int)
	hypo_pred = (y_pred < 70).astype(int)

	a_pred = np.array([hypo_pred[0]] + [True if (hypo_pred[i] == True and hypo_pred[i-1] == False) 
											  else False 
											  for i in range(1, len(hypo_pred))], ndmin = 2)

	a_true = np.array([hypo_real[0]] + [True if (hypo_real[i] == True and hypo_real[i-1] == False) 
											  else False 
											  for i in range(1, len(hypo_real))], ndmin = 2)
	return (a_true, a_pred)

	Convert glucose levels to alarm.

	Alarm state is positive if glucose at time 
	t and t-1 is < 70 and >70 at time t-2.
	
Convert glucose levels to alarm.
Alarm state is positive if glucose at time
t and t-1 is < 70 and >70 at time t-2.
Convert glucose levels to alarm . Alarm state is positive if glucose at time t and t - 1 is < 70 and > 70 at time t - 2 .
def glu_to_alarm(y_true, y_pred):
	hypo_real = (y_true < 70).astype(int)
	hypo_pred = (y_pred < 70).astype(int)
	a_pred = np.array([hypo_pred[0]] + [True if (hypo_pred[i] == True and hypo_pred[i-1] == False) 
											  else False 
											  for i in range(1, len(hypo_pred))], ndmin = 2)
	a_true = np.array([hypo_real[0]] + [True if (hypo_real[i] == True and hypo_real[i-1] == False) 
											  else False 
											  for i in range(1, len(hypo_real))], ndmin = 2)
	return (a_true, a_pred)
def glu_to_alarm ( y_true , y_pred ) : hypo_real = ( y_true < 70 ) . astype ( int ) hypo_pred = ( y_pred < 70 ) . astype ( int ) a_pred = np . array ( [ hypo_pred [ 0 ] ] + [ True if ( hypo_pred [ i ] == True and hypo_pred [ i - 1 ] == False ) else False for i in range ( 1 , len ( hypo_pred ) ) ] , ndmin = 2 ) a_true = np . array ( [ hypo_real [ 0 ] ] + [ True if ( hypo_real [ i ] == True and hypo_real [ i - 1 ] == False ) else False for i in range ( 1 , len ( hypo_real ) ) ] , ndmin = 2 ) return ( a_true , a_pred )
Convert glucose levels to alarm.
Convert glucose levels to alarm .
'''
	Convert glucose levels to alarm.

	Alarm state is positive if glucose at time 
	t and t-1 is < 70 and >70 at time t-2.
	'''
y_true
y_pred