#NEWLINE# def _fit( self , X ) : #NEWLINE# #INDENT# n_sv = self . n_components #NEWLINE# if ( self . method == 'bistochastic' ) : #NEWLINE# #INDENT# normalized_data = _bistochastic_normalize ( X ) #NEWLINE# n_sv += 1 #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( self . method == 'scale' ) : #NEWLINE# #INDENT# ( normalized_data , _ , _ ) = _scale_normalize ( X ) #NEWLINE# n_sv += 1 #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( v . method == 'log' ) : #NEWLINE# #INDENT# normalized_data = _log_normalize ( X ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# n_discard = ( 0 if ( self . method == 'log' ) else 1 ) #NEWLINE# ( u , v ) = self . _svd ( normalized_data , n_sv , n_discard ) #NEWLINE# ut = u . T #NEWLINE# vt = v . T #NEWLINE# try : #NEWLINE# #INDENT# ( n_row_clusters , n_col_clusters ) = self . n_clusters #NEWLINE# #UNINDENT# except TypeError : #NEWLINE# #INDENT# n_row_clusters = n_col_clusters = self . n_clusters #NEWLINE# #UNINDENT# best_ut = self . _fit_best_piecewise ( ut , self . n_best , n_row_clusters ) #NEWLINE# best_vt = self . _fit_best_piecewise ( vt , self . n_best , n_col_clusters ) #NEWLINE# self . row_labels_ = self . _project_and_cluster ( X , best_vt . T , n_row_clusters ) #NEWLINE# self . column_labels_ = self . _project_and_cluster ( X . T , best_ut . T , n_col_clusters ) #NEWLINE# self . rows_ = np . vstack ( ( ( self . row_labels_ == label ) for label in range ( n_row_clusters ) for _ in range ( n_col_clusters ) ) ) #NEWLINE# self . columns_ = np . vstack ( ( ( self . column_labels_ == label ) for _ in range ( n_row_clusters ) for label in range ( n_col_clusters ) ) )