#NEWLINE# def fixed_batch_size_comparison( data ) : #NEWLINE# #INDENT# all_features = [ i . astype ( int ) for i in np . linspace ( ( data . shape [ 1 ] // 10 ) , data . shape [ 1 ] , num = 5 ) ] #NEWLINE# batch_size = 1000 #NEWLINE# all_times = defaultdict ( list ) #NEWLINE# all_errors = defaultdict ( list ) #NEWLINE# for n_components in all_features : #NEWLINE# #INDENT# pca = PCA ( n_components = n_components ) #NEWLINE# rpca = RandomizedPCA ( n_components = n_components , random_state = 1999 ) #NEWLINE# ipca = IncrementalPCA ( n_components = n_components , batch_size = batch_size ) #NEWLINE# results_dict = { k : benchmark ( est , data ) for ( k , est ) in [ ( 'pca' , pca ) , ( 'ipca' , ipca ) , ( 'rpca' , rpca ) ] } #NEWLINE# for k in sorted ( results_dict . keys ( ) ) : #NEWLINE# #INDENT# all_times [ k ] . append ( results_dict [ k ] [ 'time' ] ) #NEWLINE# all_errors [ k ] . append ( results_dict [ k ] [ 'error' ] ) #NEWLINE# #UNINDENT# #UNINDENT# plot_feature_times ( all_times , batch_size , all_features , data ) #NEWLINE# plot_feature_errors ( all_errors , batch_size , ipca , data )