#NEWLINE# def test_discretize( seed = 8 ) : #NEWLINE# #INDENT# random_state = np . random . RandomState ( seed ) #NEWLINE# for n_samples in [ 50 , 100 , 150 , 500 ] : #NEWLINE# #INDENT# for n_class in range ( 2 , 10 ) : #NEWLINE# #INDENT# y_true = random_state . randint ( 0 , ( n_class + 1 ) , n_samples ) #NEWLINE# y_true = np . array ( y_true , np . float ) #NEWLINE# y_indicator = sparse . coo_matrix ( ( np . ones ( n_samples ) , ( np . arange ( n_samples ) , y_true ) ) , shape = ( n_samples , ( n_class + 1 ) ) ) #NEWLINE# y_true_noisy = ( y_indicator . toarray ( ) + ( 0.1 * random_state . randn ( n_samples , ( n_class + 1 ) ) ) ) #NEWLINE# y_pred = discretize ( y_true_noisy , random_state ) #NEWLINE# assert_greater ( adjusted_rand_score ( y_true , y_pred ) , 0.8 )