8000 DOC added example for `sklearn.feature_extraction.image.grid_to_graph… · LeoGrin/scikit-learn@c848024 · GitHub
[go: up one dir, main page]

Skip to content

Commit c848024

Browse files
ChVeenglemaitre
authored andcommitted
DOC added example for sklearn.feature_extraction.image.grid_to_graph (scikit-learn#28390)
Co-authored-by: Guillaume Lemaitre <guillaume@probabl.ai>
1 parent 7613a5f commit c848024

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

sklearn/feature_extraction/image.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,18 @@ def grid_to_graph(
237237
238238
For compatibility, user code relying on this method should wrap its
239239
calls in ``np.asarray`` to avoid type issues.
240+
241+
Examples
242+
--------
243+
>>> import numpy as np
244+
>>> from sklearn.feature_extraction.image import grid_to_graph
245+
>>> shape_img = (4, 4, 1)
246+
>>> mask = np.zeros(shape=shape_img, dtype=bool)
247+
>>> mask[[1, 2], [1, 2], :] = True
248+
>>> graph = grid_to_graph(*shape_img, mask=mask)
249+
>>> print(graph)
250+
(0, 0) 1
251+
(1, 1) 1
240252
"""
241253
return _to_graph(n_x, n_y, n_z, mask=mask, return_as=return_as, dtype=dtype)
242254

0 commit comments

Comments
 (0)
0