#NEWLINE# def fit( self , X , y , sample_weight = None ) : #NEWLINE# #INDENT# ' Prepare different things for fast computation of metrics ' #NEWLINE# ( X , y , sample_weight ) = check_xyw ( X , y , sample_weight = sample_weight ) #NEWLINE# self . _mask = numpy . array ( ( y == self . uniform_label ) ) #NEWLINE# assert ( sum ( self . _mask ) > 0 ) , 'No events of uniform class!' #NEWLINE# self . _masked_weight = sample_weight [ self . _mask ] #NEWLINE# X_part = numpy . array ( take_features ( X , self . uniform_features ) ) [ self . _mask , : ] #NEWLINE# neighbours = NearestNeighbors ( n_neighbors = self . n_neighbours , algorithm = 'kd_tree' ) . fit ( X_part ) #NEWLINE# ( _ , self . _groups_indices ) = neighbours . kneighbors ( X_part ) #NEWLINE# self . _group_weights = ut . compute_group_weights ( self . _groups_indices , sample_weight = self . _masked_weight )