8000 DOC improve example of PatchExtractor (#26002) · scikit-learn/scikit-learn@5401b59 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5401b59

Browse files
authored
DOC improve example of PatchExtractor (#26002)
1 parent 2fbded2 commit 5401b59

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

sklearn/feature_extraction/image.py

Lines changed: 7 additions & 3 deletions
9F19
Original file line numberDiff line numberDiff line change
@@ -532,12 +532,16 @@ class PatchExtractor(TransformerMixin, BaseEstimator):
532532
>>> from sklearn.feature_extraction import image
533533
>>> # Use the array data from the second image in this dataset:
534534
>>> X = load_sample_images().images[1]
535+
>>> X = X[None, ...]
535536
>>> print(f"Image shape: {X.shape}")
536-
Image shape: (427, 640, 3)
537-
>>> pe = image.PatchExtractor(patch_size=(2, 2))
537+
Image shape: (1, 427, 640, 3)
538+
>>> pe = image.PatchExtractor(patch_size=(10, 10))
538539
>>> pe_trans = pe.transform(X)
539540
>>> print(f"Patches shape: {pe_trans.shape}")
540-
Patches shape: (545706, 2, 2)
541+
Patches shape: (263758, 10, 10, 3)
542+
>>> X_reconstructed = image.reconstruct_from_patches_2d(pe_trans, X.shape[1:])
543+
>>> print(f"Reconstructed shape: {X_reconstructed.shape}")
544+
Reconstructed shape: (427, 640, 3)
541545
"""
542546

543547
_parameter_constraints: dict = {

0 commit comments

Comments
 (0)
0