#NEWLINE# def benchmark( estimator , data ) : #NEWLINE# #INDENT# gc . collect ( ) #NEWLINE# print ( ( 'Benching %s' % estimator ) ) #NEWLINE# t0 = time ( ) #NEWLINE# estimator . fit ( data ) #NEWLINE# training_time = ( time ( ) - t0 ) #NEWLINE# data_t = estimator . transform ( data ) #NEWLINE# data_r = estimator . inverse_transform ( data_t ) #NEWLINE# reconstruction_error = np . mean ( np . abs ( ( data - data_r ) ) ) #NEWLINE# return { #NEWLINE# #INDENT# 'time' : training_time , #NEWLINE# 'error' : reconstruction_error , #NEWLINE# #UNINDENT# }