#NEWLINE# def predict( self , resource ) : #NEWLINE# #INDENT# n = resource . get ( 'n' ) #NEWLINE# key_list = [ ] #NEWLINE# for i in range ( n ) : #NEWLINE# #INDENT# key_list . append ( ( 'Xsum_' + str ( i ) ) ) #NEWLINE# key_list . append ( ( 'T_' + str ( i ) ) ) #NEWLINE# #UNINDENT# key_value_dict = resource . get_many ( key_list ) #NEWLINE# sumX = [ ] #NEWLINE# T = [ ] #NEWLINE# for i in range ( n ) : #NEWLINE# #INDENT# sumX . append ( key_value_dict [ ( 'Xsum_' + str ( i ) ) ] ) #NEWLINE# T . append ( key_value_dict [ ( 'T_' + str ( i ) ) ] ) #NEWLINE# #UNINDENT# mu = numpy . zeros ( n ) #NEWLINE# for i in range ( n ) : #NEWLINE# #INDENT# if ( ( T [ i ] == 0 ) or ( mu [ i ] == float ( 'inf' ) ) ) : #NEWLINE# #INDENT# mu [ i ] = ( - 1 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# mu [ i ] = ( sumX [ i ] / T [ i ] ) #NEWLINE# #UNINDENT# #UNINDENT# prec = [ numpy . sqrt ( ( 1.0 / max ( 1 , t ) ) ) for t in T ] #NEWLINE# return ( mu . tolist ( ) , prec )