#NEWLINE# def bench_a( X , dataset_name , power_iter , n_oversamples , n_comps ) : #NEWLINE# #INDENT# all_time = defaultdict ( list ) #NEWLINE# if enable_spectral_norm : #NEWLINE# #INDENT# all_spectral = defaultdict ( list ) #NEWLINE# X_spectral_norm = norm_diff ( X , norm = 2 , msg = False ) #NEWLINE# #UNINDENT# all_frobenius = defaultdict ( list ) #NEWLINE# X_fro_norm = norm_diff ( X , norm = 'fro' , msg = False ) #NEWLINE# for pi in power_iter : #NEWLINE# #INDENT# for pm in [ 'none' , 'LU' , 'QR' ] : #NEWLINE# #INDENT# print ( ( 'n_iter = %d on sklearn - %s' % ( pi , pm ) ) ) #NEWLINE# ( U , s , V , time ) = svd_timing ( X , n_comps , n_iter = pi , power_iteration_normalizer = pm , n_oversamples = n_oversamples ) #NEWLINE# label = ( 'sklearn - %s' % pm ) #NEWLINE# all_time [ label ] . append ( n_comps ) #NEWLINE# if enable_spectral_norm : #NEWLINE# #INDENT# A = U . dot ( np . diag ( s ) . dot ( V ) ) #NEWLINE# all_spectral [ label ] . append ( ( norm_diff ( ( X - A ) , norm = 2 ) / X_spectral_norm ) ) #NEWLINE# #UNINDENT# f = scalable_frobenius_norm_discrepancy ( X , U , s , V ) #NEWLINE# all_frobenius [ label ] . append ( ( f / X_fro_norm ) ) #NEWLINE# #UNINDENT# if fbpca_available : #NEWLINE# #INDENT# print ( ( 'n_iter = %d on fbca' % pi ) ) #NEWLINE# ( U , s , V , time ) = svd_timing ( X , n_comps , n_iter = pi , power_iteration_normalizer = pm , n_oversamples = n_oversamples , method = 'fbpca' ) #NEWLINE# label = 'fbpca' #NEWLINE# all_time [ label ] . append ( time ) #NEWLINE# if enable_spectral_norm : #NEWLINE# #INDENT# A = U . dot ( np . diag ( s ) . dot ( V ) ) #NEWLINE# all_spectral [ label ] . append ( ( norm_diff ( ( X - A ) , norm = 2 ) / X_spectral_norm ) ) #NEWLINE# #UNINDENT# f = scalable_frobenius_norm_discrepancy ( X , U , s , V ) #NEWLINE# all_frobenius [ label ] . append ( ( f / X_fro_norm ) ) #NEWLINE# #UNINDENT# #UNINDENT# if enable_spectral_norm : #NEWLINE# #INDENT# title = ( '%s: spectral norm diff vs running time' % dataset_name ) #NEWLINE# plot_time_vs_s ( all_time , all_spectral , power_iter , title ) #NEWLINE# #UNINDENT# title = ( '%s: Frobenius norm diff vs running time' % dataset_name ) #NEWLINE# plot_time_vs_s ( all_time , all_frobenius , power_iter , title )