DOC add example to sklearn.utils.indices_to_mask
@@ -493,11 +493,19 @@ def indices_to_mask(indices, mask_length):
List of integers treated as indices.
mask_length : int
Length of boolean mask to be generated.
+ This parameter must be greater than max(indices)
Returns
-------
mask : 1d boolean nd-array
Boolean array that is True where indices are present, else False.
+
+ Examples
+ --------
+ >>> from sklearn.utils import indices_to_mask
+ >>> indices = [1, 2 , 3, 4]
+ >>> indices_to_mask(indices, 5)
+ array([False, True, True, True, True], dtype=bool)
"""
if mask_length <= np.max(indices):
raise ValueError("mask_length must be greater than max(indices)")
