8000 DOC Add a docstring example for the BiclusterMixin class (#28129) · scikit-learn/scikit-learn@54de830 · GitHub
[go: up one dir, main page]

Skip to content

Commit 54de830

Browse files
DOC Add a docstring example for the BiclusterMixin class (#28129)
Co-authored-by: Guillaume Lemaitre <g.lemaitre58@gmail.com>
1 parent 65c907d commit 54de830

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

sklearn/base.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -889,7 +889,32 @@ def _more_tags(self):
889889

890890

891891
class BiclusterMixin:
892-
"""Mixin class for all bicluster estimators in scikit-learn."""
892+
"""Mixin class for all bicluster estimators in scikit-learn.
893+
894+
This mixin defines the following functionality:
895+
896+
- `biclusters_` property that returns the row and column indicators;
897+
- `get_indices` method that returns the row and column indices of a bicluster;
898+
- `get_shape` method that returns the shape of a bicluster;
899+
- `get_submatrix` method that returns the submatrix corresponding to a bicluster.
900+
901+
Examples
902+
--------
903+
>>> import numpy as np
904+
>>> from sklearn.base import BaseEstimator, BiclusterMixin
905+
>>> class DummyBiClustering(BiclusterMixin, BaseEstimator):
906+
... def fit(self, X, y=None):
907+
... self.rows_ = np.ones(shape=(1, X.shape[0]), dtype=bool)
908+
... self.columns_ = np.ones(shape=(1, X.shape[1]), dtype=bool)
909+
... return self
910+
>>> X = np.array([[1, 1], [2, 1], [1, 0],
911+
... [4, 7], [3, 5], [3, 6]])
912+
>>> bicluster = DummyBiClustering().fit(X)
913+
>>> hasattr(bicluster, "biclusters_")
914+
True
915+
>>> bicluster.get_indices(0)
916+
(array([0, 1, 2, 3, 4, 5]), array([0, 1]))
917+
"""
893918

894919
@property
895920
def biclusters_(self):

0 commit comments

Comments
 (0)
0