當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。