当前位置: 首页>>代码示例>>Python>>正文


Python fixes.bincount方法代码示例

本文整理汇总了Python中sklearn.utils.fixes.bincount方法的典型用法代码示例。如果您正苦于以下问题:Python fixes.bincount方法的具体用法?Python fixes.bincount怎么用?Python fixes.bincount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sklearn.utils.fixes的用法示例。


在下文中一共展示了fixes.bincount方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _iter_indices

# 需要导入模块: from sklearn.utils import fixes [as 别名]
# 或者: from sklearn.utils.fixes import bincount [as 别名]
def _iter_indices(self):
        rng = np.random.RandomState(self.random_state)
        cls_count = bincount(self.y_indices)

        for n in range(self.n_iter):
            train = []
            test = []

            for i, cls in enumerate(self.classes):
                sample_size = int(cls_count[i]*(1-self.test_size))
                randint = rng.randint(cls_count[i], size=sample_size)
                aidx = np.where((self.y == cls))[0]
                iidx = aidx[randint]
                oidx = aidx[list(set(range(cls_count[i])).difference(set(randint)))]

                train.extend(iidx)
                test.extend(oidx)

            train = rng.permutation(train)
            test = rng.permutation(test)

            yield train, test 
开发者ID:ChenglongChen,项目名称:kaggle-HomeDepot,代码行数:24,代码来源:extreme_ensemble_selection.py

示例2: _document_frequency

# 需要导入模块: from sklearn.utils import fixes [as 别名]
# 或者: from sklearn.utils.fixes import bincount [as 别名]
def _document_frequency(X):
    """Count the number of non-zero values for each feature in sparse X."""

    if sp.isspmatrix_csr(X):
        # return np.sum(X,axis=0)
        return bincount(X.indices, minlength=X.shape[1])

    else:

        return np.diff(sp.csc_matrix(X, copy=False).indptr) 
开发者ID:prozhuchen,项目名称:2016CCF-sougou,代码行数:12,代码来源:STFIWF.py


注:本文中的sklearn.utils.fixes.bincount方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。