#NEWLINE# def generate_samples( self , x , knns , knnLabels , cl ) : #NEWLINE# #INDENT# new_data = [ ] #NEWLINE# new_labels = [ ] #NEWLINE# for ( ind , elem ) in enumerate ( x ) : #NEWLINE# #INDENT# min_knns = [ ele for ( index , ele ) in enumerate ( knns [ ind ] [ 1 : ( - 1 ) ] ) if ( knnLabels [ ind ] [ ( index + 1 ) ] == cl ) ] #NEWLINE# if ( not min_knns ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# for i in range ( 0 , int ( self . gi [ ind ] ) ) : #NEWLINE# #INDENT# randi = self . random_state_ . random_integers ( 0 , ( len ( min_knns ) - 1 ) ) #NEWLINE# l = self . random_state_ . random_sample ( ) #NEWLINE# si = ( self . X [ elem ] + ( ( self . X [ min_knns [ randi ] ] - self . X [ elem ] ) * l ) ) #NEWLINE# new_data . append ( si ) #NEWLINE# new_labels . append ( self . y [ elem ] ) #NEWLINE# self . num_new += 1 #NEWLINE# #UNINDENT# #UNINDENT# return ( np . asarray ( new_data ) , np . asarray ( new_labels ) )