@@ -103,18 +103,6 @@ def test_parameter_checks():
103103 assert_raises (ValueError ,
104104 lambda : GradientBoostingClassifier ().feature_importances_ )
105105
106- # binomial deviance requires ``n_classes == 2``.
107- assert_raises (ValueError ,
108- lambda X , y : GradientBoostingClassifier (
109- loss = 'bdeviance' ).fit (X , y ),
110- X , [0 , 0 , 1 , 1 , 2 , 2 ])
111-
112- # multinomial deviance requires ``n_classes > 2``.
113- assert_raises (ValueError ,
114- lambda X , y : GradientBoostingClassifier (
115- loss = 'mdeviance' ).fit (X , y ),
116- X , [0 , 0 , 1 , 1 , 1 , 0 ])
117-
118106 # deviance requires ``n_classes >= 2``.
119107 assert_raises (ValueError ,
120108 lambda X , y : GradientBoostingClassifier (
@@ -133,10 +121,6 @@ def test_loss_function():
133121 GradientBoostingClassifier (loss = 'huber' ).fit , X , y )
134122 assert_raises (ValueError ,
135123 GradientBoostingRegressor (loss = 'deviance' ).fit , X , y )
136- assert_raises (ValueError ,
137- GradientBoostingRegressor (loss = 'bdeviance' ).fit , X , y )
138- assert_raises (ValueError ,
139- GradientBoostingRegressor (loss = 'mdeviance' ).fit , X , y )
140124
141125
142126def test_classification_synthetic ():
@@ -596,3 +580,21 @@ def test_more_verbose_output():
596580 n_lines = sum (1 for l in verbose_output .readlines ())
597581 # 100 lines for n_estimators==100
598582 assert_equal (100 , n_lines )
583+
584+
585+ def test_warn_deviance ():
586+ """Test if mdeviance and bdeviance give deprecated warning. """
587+ for loss in ('bdeviance' , 'mdeviance' ):
588+ with warnings .catch_warnings (record = True ) as w :
589+ # This will raise a DataConversionWarning that we want to
590+ # "always" raise, elsewhere the warnings gets ignored in the
591+ # later tests, and the tests that check for this warning fail
592+ warnings .simplefilter ("always" , DataConversionWarning )
593+ clf = GradientBoostingClassifier (loss = loss )
594+ try :
595+ clf .fit (X , y )
596+ except :
597+ # mdeviance will raise ValueError because only 2 classes
598+ pass
599+ # deprecated warning for bdeviance and mdeviance
600+ assert len (w ) == 1
0 commit comments