BiclusterMixin#

class sklearn.base.BiclusterMixin[源代码]#

scikit-learn中所有双聚类估计器的混合类。

此mixin定义了以下功能:

  • biclusters_ 返回行和列指示符的属性;

  • get_indices 返回双集群的行和列索引的方法;

  • get_shape 返回双集群形状的方法;

  • get_submatrix 返回与双集群对应的子矩阵的方法。

示例

>>> import numpy as np
>>> from sklearn.base import BaseEstimator, BiclusterMixin
>>> class DummyBiClustering(BiclusterMixin, BaseEstimator):
...     def fit(self, X, y=None):
...         self.rows_ = np.ones(shape=(1, X.shape[0]), dtype=bool)
...         self.columns_ = np.ones(shape=(1, X.shape[1]), dtype=bool)
...         return self
>>> X = np.array([[1, 1], [2, 1], [1, 0],
...               [4, 7], [3, 5], [3, 6]])
>>> bicluster = DummyBiClustering().fit(X)
>>> hasattr(bicluster, "biclusters_")
True
>>> bicluster.get_indices(0)
(array([0, 1, 2, 3, 4, 5]), array([0, 1]))
get_indices(i)[源代码]#

对象的行索引和列索引 i 第二个二元集群。

只有在以下情况下才有效 rows_columns_ 属性存在。

参数:
iint

集群的索引。

返回:
row_indndray,dype =NP.intp

数据集中属于双集群的行的索引。

col_indndray,dype =NP.intp

数据集中属于双聚类的列的索引。

get_shape(i)[源代码]#

形状 i 第二个二元集群。

参数:
iint

集群的索引。

返回:
n_rowsint

双集群中的行数。

n_colsint

双集群中的列数。

get_submatrix(i, data)[源代码]#

返回双集群对应的子矩阵 i .

参数:
iint

集群的索引。

data形状类似阵列(n_samples,n_features)

数据。

返回:
submatrix形状的nd数组(n_rows,n_RST)

双聚类对应的子矩阵 i .

注意到

适用于稀疏矩阵。只有在以下情况下才有效 rows_columns_ 属性存在。