#NEWLINE# def predict( self , X , batch_size = 128 , verbose = 0 ) : #NEWLINE# #INDENT# predictions = map ( ( lambda model : model . predict ( X , batch_size , verbose ) ) , self . model_list ) #NEWLINE# nb_preds = len ( X ) #NEWLINE# nb_classes = predictions [ 0 ] . shape [ 1 ] #NEWLINE# if ( self . voting == 'hard' ) : #NEWLINE# #INDENT# for ( i , pred ) in enumerate ( predictions ) : #NEWLINE# #INDENT# pred = map ( ( lambda probas : np . argmax ( probas , axis = ( - 1 ) ) ) , pred ) #NEWLINE# predictions [ i ] = np . asarray ( pred ) . reshape ( nb_preds , 1 ) #NEWLINE# #UNINDENT# argmax_list = list ( np . concatenate ( predictions , axis = 1 ) ) #NEWLINE# votes = np . asarray ( map ( ( lambda arr : max ( set ( arr ) ) ) , argmax_list ) ) #NEWLINE# #UNINDENT# if ( self . voting == 'soft' ) : #NEWLINE# #INDENT# for ( i , pred ) in enumerate ( predictions ) : #NEWLINE# #INDENT# pred = map ( ( lambda probas : ( probas * self . weights [ i ] ) ) , pred ) #NEWLINE# predictions [ votes ] = np . asarray ( pred ) . reshape ( nb_preds , nb_classes , 1 ) #NEWLINE# #UNINDENT# weighted_preds = np . concatenate ( predictions , axis = 2 ) #NEWLINE# weighted_avg = np . mean ( weighted_preds , axis = 2 ) #NEWLINE# votes = np . argmax ( weighted_avg , axis = 1 ) #NEWLINE# #UNINDENT# return votes