#NEWLINE# def test_score_sample_weight( ) : #NEWLINE# #INDENT# from sklearn.tree import DecisionTreeClassifier #NEWLINE# from sklearn.tree import DecisionTreeRegressor #NEWLINE# from sklearn import datasets #NEWLINE# rng = np . random . RandomState ( 0 ) #NEWLINE# estimators = [ DecisionTreeClassifier ( max_depth = 2 ) , DecisionTreeRegressor ( max_depth = 2 ) ] #NEWLINE# sets = [ datasets . load_iris ( ) , datasets . load_boston ( ) ] #NEWLINE# for ( est , ds ) in zip ( estimators , sets ) : #NEWLINE# #INDENT# est . fit ( ds . data , ds . target ) #NEWLINE# sample_weight = rng . randint ( 1 , 10 , size = len ( ds . target ) ) #NEWLINE# assert_not_equal ( est . score ( ds . data , ds . target ) , est . score ( ds . data , ds . target , sample_weight = sample_weight ) , msg = 'Unweighted and weighted scores are unexpectedly equal' )