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


Python decomposition.RandomizedPCA方法代码示例

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


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

示例1: __init__

# 需要导入模块: from sklearn import decomposition [as 别名]
# 或者: from sklearn.decomposition import RandomizedPCA [as 别名]
def __init__(self, k=None, mle_components=False, varfrac=None,
                 randomize=False, whiten=False):
        n_specs = sum(1 for x in [k, mle_components, varfrac] if x)
        if n_specs > 1:
            msg = "can't specify number of components in more than one way"
            raise TypeError(msg)
        if n_specs == 0:
            varfrac = DEFAULT_VARFRAC

        if randomize:
            if k is None:
                raise TypeError("can't do random PCA without a specific k")
            pca = RandomizedPCA(k, whiten=whiten)
        else:
            if k is not None:
                n_components = k
            elif mle_components:
                n_components = 'mle'
            elif varfrac is not None:
                n_components = varfrac
            pca = PCA(n_components, whiten=whiten)
        super(BagPCA, self).__init__(pca) 
开发者ID:djsutherland,项目名称:skl-groups,代码行数:24,代码来源:preprocessing.py

示例2: test_deprecation_randomized_pca

# 需要导入模块: from sklearn import decomposition [as 别名]
# 或者: from sklearn.decomposition import RandomizedPCA [as 别名]
def test_deprecation_randomized_pca():
    rng = np.random.RandomState(0)
    X = rng.random_sample((5, 4))

    depr_message = ("Class RandomizedPCA is deprecated; RandomizedPCA was "
                    "deprecated in 0.18 and will be "
                    "removed in 0.20. Use PCA(svd_solver='randomized') "
                    "instead. The new implementation DOES NOT store "
                    "whiten ``components_``. Apply transform to get them.")

    def fit_deprecated(X):
        global Y
        rpca = RandomizedPCA(random_state=0)
        Y = rpca.fit_transform(X)

    assert_warns_message(DeprecationWarning, depr_message, fit_deprecated, X)
    Y_pca = PCA(svd_solver='randomized', random_state=0).fit_transform(X)
    assert_array_almost_equal(Y, Y_pca) 
开发者ID:alvarobartt,项目名称:twitter-stock-recommendation,代码行数:20,代码来源:test_pca.py

示例3: reduce_randomizedPCA

# 需要导入模块: from sklearn import decomposition [as 别名]
# 或者: from sklearn.decomposition import RandomizedPCA [as 别名]
def reduce_randomizedPCA(x):
    '''
        Reduce the dimensions using Randomized PCA algorithm
    '''
    # create the CCA object
    randomPCA = dc.RandomizedPCA(n_components=2, whiten=True,
        copy=False)

    # learn the principal components from all the features
    return randomPCA.fit(x) 
开发者ID:drabastomek,项目名称:practicalDataAnalysisCookbook,代码行数:12,代码来源:reduce_randomizedPCA.py

示例4: pca_algorithm

# 需要导入模块: from sklearn import decomposition [as 别名]
# 或者: from sklearn.decomposition import RandomizedPCA [as 别名]
def pca_algorithm(self):
        """ Deterimine PCA algorithm to use. """
        if self.rotation_algo == 'randomized':
            return RandomizedPCA(random_state=self.random_state)
        elif self.rotation_algo == 'pca':
            return PCA()
        else:
            raise ValueError("`rotation_algo` must be either "
                             "'pca' or 'randomized'.") 
开发者ID:joshloyal,项目名称:RotationForest,代码行数:11,代码来源:rotation_forest.py


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