#NEWLINE# def test_sample_weight_invariance( n_samples = 50 ) : #NEWLINE# #INDENT# random_state = check_random_state ( 0 ) #NEWLINE# random_state = check_random_state ( 0 ) #NEWLINE# y_true = random_state . randint ( 0 , 2 , size = ( random_state , ) ) #NEWLINE# y_pred = random_state . randint ( 0 , 2 , size = ( n_samples , ) ) #NEWLINE# y_score = random_state . random_sample ( size = ( n_samples , ) ) #NEWLINE# for name in ALL_METRICS : #NEWLINE# #INDENT# if ( ( name in METRICS_WITHOUT_SAMPLE_WEIGHT ) or ( name in METRIC_UNDEFINED_BINARY ) ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# metric = ALL_METRICS [ name ] #NEWLINE# if ( name in THRESHOLDED_METRICS ) : #NEWLINE# #INDENT# ( yield ( check_sample_weight_invariance , name , metric , y_true , y_score ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# ( yield ( check_sample_weight_invariance , name , metric , y_true , y_pred ) ) #NEWLINE# #UNINDENT# #UNINDENT# random_state = check_random_state ( 0 ) #NEWLINE# y_true = random_state . randint ( 0 , 5 , size = ( n_samples , ) ) #NEWLINE# y_pred = random_state . randint ( 0 , 5 , size = ( n_samples , ) ) #NEWLINE# y_score = random_state . random_sample ( size = ( n_samples , 5 ) ) #NEWLINE# for name in ALL_METRICS : #NEWLINE# #INDENT# if ( ( name in METRICS_WITHOUT_SAMPLE_WEIGHT ) or ( name in METRIC_UNDEFINED_BINARY_MULTICLASS ) ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# metric = ALL_METRICS [ name ] #NEWLINE# if ( name in THRESHOLDED_METRICS ) : #NEWLINE# #INDENT# ( yield ( check_sample_weight_invariance , name , metric , y_true , y_score ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# ( yield ( check_sample_weight_invariance , name , metric , y_true , y_pred ) ) #NEWLINE# #UNINDENT# #UNINDENT# ( _ , ya ) = make_multilabel_classification ( n_features = 1 , n_classes = 20 , random_state = 0 , n_samples = 100 , allow_unlabeled = False ) #NEWLINE# ( _ , yb ) = make_multilabel_classification ( n_features = 1 , n_classes = 20 , random_state = 1 , n_samples = 100 , allow_unlabeled = False ) #NEWLINE# y_true = np . vstack ( [ ya , yb ] ) #NEWLINE# y_pred = np . vstack ( [ ya , ya ] ) #NEWLINE# y_score = random_state . randint ( 1 , 4 , size = y_true . shape ) #NEWLINE# for name in ( ( MULTILABELS_METRICS + THRESHOLDED_MULTILABEL_METRICS ) + MULTIOUTPUT_METRICS ) : #NEWLINE# #INDENT# if ( name in METRICS_WITHOUT_SAMPLE_WEIGHT ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# metric = ALL_METRICS [ name ] #NEWLINE# if ( name in THRESHOLDED_METRICS ) : #NEWLINE# #INDENT# ( yield ( check_sample_weight_invariance , name , metric , y_true , y_score ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# ( yield ( check_sample_weight_invariance , name , metric , y_true , y_pred ) )