@@ -309,6 +309,20 @@ def make_classification(
309309 return X , y
310310
311311
312+ @validate_params (
313+ {
314+ "n_samples" : [Interval (Integral , 1 , None , closed = "left" )],
315+ "n_features" : [Interval (Integral , 1 , None , closed = "left" )],
316+ "n_classes" : [Interval (Integral , 1 , None , closed = "left" )],
317+ "n_labels" : [Interval (Integral , 0 , None , closed = "left" )],
318+ "length" : [Interval (Integral , 1 , None , closed = "left" )],
319+ "allow_unlabeled" : ["boolean" ],
320+ "sparse" : ["boolean" ],
321+ "return_indicator" : [StrOptions ({"dense" , "sparse" }), "boolean" ],
322+ "return_distributions" : ["boolean" ],
323+ "random_state" : ["random_state" ],
324+ }
325+ )
312326def make_multilabel_classification (
313327 n_samples = 100 ,
314328 n_features = 20 ,
@@ -398,18 +412,6 @@ def make_multilabel_classification(
398412 The probability of each feature being drawn given each class.
399413 Only returned if ``return_distributions=True``.
400414 """
401- if n_classes < 1 :
402- raise ValueError (
403- "'n_classes' should be an integer greater than 0. Got {} instead." .format (
404- n_classes
405- )
406- )
407- if length < 1 :
408- raise ValueError (
409- "'length' should be an integer greater than 0. Got {} instead." .format (
410- length
411- )
412- )
413415
414416 generator = check_random_state (random_state )
415417 p_c = generator .uniform (size = n_classes )
@@ -469,8 +471,6 @@ def sample_example():
469471 if return_indicator in (True , "sparse" , "dense" ):
470472 lb = MultiLabelBinarizer (sparse_output = (return_indicator == "sparse" ))
471473 Y = lb .fit ([range (n_classes )]).transform (Y )
472- elif return_indicator is not False :
473- raise ValueError ("return_indicator must be either 'sparse', 'dense' or False." )
474474 if return_distributions :
475475 return X , Y , p_c , p_w_c
476476 return X , Y
0 commit comments