#NEWLINE# def compute_bench( samples_range , features_range , n_iter = 3 , rank = 50 ) : #NEWLINE# #INDENT# it = 0 #NEWLINE# results = defaultdict ( ( lambda : [ ] ) ) #NEWLINE# max_it = ( len ( samples_range ) * len ( features_range ) ) #NEWLINE# for n_samples in samples_range : #NEWLINE# #INDENT# for n_features in features_range : #NEWLINE# #INDENT# it += 1 #NEWLINE# print ( '====================' ) #NEWLINE# print ( ( 'Iteration %03d of %03d' % ( it , max_it ) ) ) #NEWLINE# print ( '====================' ) #NEWLINE# X = make_low_rank_matrix ( n_samples , n_features , effective_rank = rank , tail_strength = 0.2 ) #NEWLINE# gc . collect ( ) #NEWLINE# print ( 'benchmarking scipy svd: ' ) #NEWLINE# tstart = time ( ) #NEWLINE# svd ( X , full_matrices = False ) #NEWLINE# results [ 'scipy svd' ] . append ( ( time ( ) - tstart ) ) #NEWLINE# gc . collect ( ) #NEWLINE# print ( 'benchmarking scikit-learn randomized_svd: n_iter=0' ) #NEWLINE# tstart = time ( ) #NEWLINE# randomized_svd ( X , rank , n_iter = 0 ) #NEWLINE# results [ 'scikit-learn randomized_svd (n_iter=0)' ] . append ( ( time ( ) - tstart ) ) #NEWLINE# gc . collect ( ) #NEWLINE# print ( ( 'benchmarking scikit-learn randomized_svd: n_iter=%d ' % n_iter ) ) #NEWLINE# tstart = time ( ) #NEWLINE# randomized_svd ( X , rank , n_iter = n_iter ) #NEWLINE# results [ ( 'scikit-learn randomized_svd (n_iter=%d)' % n_iter ) ] . append ( ( time ( ) - tstart ) ) #NEWLINE# #UNINDENT# #UNINDENT# return results