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


Python decomposition.FastICA方法代码示例

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


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

示例1: fit_fastICA

# 需要导入模块: from sklearn import decomposition [as 别名]
# 或者: from sklearn.decomposition import FastICA [as 别名]
def fit_fastICA(data):
    '''
        Fit the model with fast ICA principal components
    '''
    # keyword parameters for the PCA
    kwrd_params = {
        'n_components': 5, 
        'algorithm': 'parallel', 
        'whiten': True
    }

    # reduce the data
    reduced = reduceDimensions(cd.FastICA, 
        data, **kwrd_params)

    # prepare the data for the classifier
    data_l = prepare_data(data, reduced, 
        kwrd_params['n_components'])

    # fit the model
    class_fit_predict_print(data_l) 
开发者ID:drabastomek,项目名称:practicalDataAnalysisCookbook,代码行数:23,代码来源:reduce_kNN.py

示例2: dim_reduction_method

# 需要导入模块: from sklearn import decomposition [as 别名]
# 或者: from sklearn.decomposition import FastICA [as 别名]
def dim_reduction_method(self):
        """
        select dimensionality reduction method
        """
        if self.dim_reduction=='pca':
            return PCA()
        elif self.dim_reduction=='factor-analysis':
            return FactorAnalysis()
        elif self.dim_reduction=='fast-ica':
            return FastICA()
        elif self.dim_reduction=='kernel-pca':
            return KernelPCA()
        elif self.dim_reduction=='sparse-pca':
            return SparsePCA()
        elif self.dim_reduction=='truncated-svd':
            return TruncatedSVD()
        elif self.dim_reduction!=None:
            raise ValueError('%s is not a supported dimensionality reduction method. Valid inputs are: \
                             "pca","factor-analysis","fast-ica,"kernel-pca","sparse-pca","truncated-svd".' 
                             %(self.dim_reduction)) 
开发者ID:arnaudvl,项目名称:ml-parameter-optimization,代码行数:22,代码来源:ml_tune.py

示例3: test_objectmapper

# 需要导入模块: from sklearn import decomposition [as 别名]
# 或者: from sklearn.decomposition import FastICA [as 别名]
def test_objectmapper(self):
        df = pdml.ModelFrame([])
        self.assertIs(df.decomposition.PCA, decomposition.PCA)
        self.assertIs(df.decomposition.IncrementalPCA,
                      decomposition.IncrementalPCA)
        self.assertIs(df.decomposition.KernelPCA, decomposition.KernelPCA)
        self.assertIs(df.decomposition.FactorAnalysis,
                      decomposition.FactorAnalysis)
        self.assertIs(df.decomposition.FastICA, decomposition.FastICA)
        self.assertIs(df.decomposition.TruncatedSVD, decomposition.TruncatedSVD)
        self.assertIs(df.decomposition.NMF, decomposition.NMF)
        self.assertIs(df.decomposition.SparsePCA, decomposition.SparsePCA)
        self.assertIs(df.decomposition.MiniBatchSparsePCA,
                      decomposition.MiniBatchSparsePCA)
        self.assertIs(df.decomposition.SparseCoder, decomposition.SparseCoder)
        self.assertIs(df.decomposition.DictionaryLearning,
                      decomposition.DictionaryLearning)
        self.assertIs(df.decomposition.MiniBatchDictionaryLearning,
                      decomposition.MiniBatchDictionaryLearning)

        self.assertIs(df.decomposition.LatentDirichletAllocation,
                      decomposition.LatentDirichletAllocation) 
开发者ID:pandas-ml,项目名称:pandas-ml,代码行数:24,代码来源:test_decomposition.py

示例4: ICA

# 需要导入模块: from sklearn import decomposition [as 别名]
# 或者: from sklearn.decomposition import FastICA [as 别名]
def ICA(data, dim):
    ica = FastICA(n_components=dim)
    ica.fit(data)
    return ica.transform(data) 
开发者ID:cxy1997,项目名称:MNIST-baselines,代码行数:6,代码来源:utils.py

示例5: bsoid_umap_embed

# 需要导入模块: from sklearn import decomposition [as 别名]
# 或者: from sklearn.decomposition import FastICA [as 别名]
def bsoid_umap_embed(f_10fps_sc, umap_params=UMAP_PARAMS):
    """
    Trains UMAP (unsupervised) given a set of features based on (x,y) positions
    :param f_10fps_sc: 2D array, standardized/session features
    :param umap_params: dict, UMAP params in GLOBAL_CONFIG
    :return trained_umap: object, trained UMAP transformer
    :return umap_embeddings: 2D array, embedded UMAP space
    """
    ###### So far, use of PCA is not necessary. If, however, features go beyond 100, consider taking top 50 PCs #####
    # if f_10fps_sc.shape[0] > 50:
    #     logging.info('Compressing {} instances from {} D '
    #                  'into {} D using PCA'.format(f_10fps_sc.shape[1], f_10fps_sc.shape[0],
    #                                               50))
    #     feats_train = PCA(n_components=50, random_state=23).fit_transform(f_10fps_sc.T)
    #     pca = PCA(n_components=50).fit(f_10fps_sc.T)
    #     logging.info('Done linear transformation with PCA.')
    #     logging.info('The top {} Principal Components '
    #                  'explained {}% variance'.format(50, 100 * np.sum(pca.explained_variance_ratio_)))
    ################ FastICA potentially useful for demixing signal ################
    # lowd_feats = FastICA(n_components=10, random_state=23).fit_transform(f_10fps.T)
    # feats_train = lowd_feats
    feats_train = f_10fps_sc.T
    logging.info('Transforming all {} instances from {} D into {} D'.format(feats_train.shape[0],
                                                                            feats_train.shape[1],
                                                                            umap_params.get('n_components')))
    trained_umap = umap.UMAP(n_neighbors=int(round(np.sqrt(feats_train.shape[0]))),  # power law
                             **umap_params).fit(feats_train)
    umap_embeddings = trained_umap.embedding_
    logging.info('Done non-linear transformation with UMAP from {} D into {} D.'.format(feats_train.shape[1],
                                                                                        umap_embeddings.shape[1]))
    return trained_umap, umap_embeddings 
开发者ID:YttriLab,项目名称:B-SOID,代码行数:33,代码来源:train.py

示例6: __init__

# 需要导入模块: from sklearn import decomposition [as 别名]
# 或者: from sklearn.decomposition import FastICA [as 别名]
def __init__(self, **kwargs):
        super().__init__()
        self.estimator = sk_d.FastICA(**kwargs) 
开发者ID:minerva-ml,项目名称:open-solution-value-prediction,代码行数:5,代码来源:feature_extraction.py

示例7: calculate

# 需要导入模块: from sklearn import decomposition [as 别名]
# 或者: from sklearn.decomposition import FastICA [as 别名]
def calculate(self, n_components: int = 4, **kwargs) -> Tuple[np.ndarray, np.ndarray]:
        if n_components is None:
            n_components = self.X.shape[-1]

        mdl = FastICA(n_components=n_components, **kwargs)
        self.ims = mdl.fit_transform(self.X.collapse()).reshape(self.X.data.shape[:-1] + (n_components,))
        self.spcs = mdl.components_.transpose()

        return self.ims, self.spcs 
开发者ID:priyankshah7,项目名称:hypers,代码行数:11,代码来源:decomposition.py

示例8: img2_coord

# 需要导入模块: from sklearn import decomposition [as 别名]
# 或者: from sklearn.decomposition import FastICA [as 别名]
def img2_coord(img, init=None):

    assert np.max(img) <= 1.0

    if init is None:
        init = np.zeros((img.shape[0] + 200, img.shape[1] + 200))

    init[100:-100, 100:-100] = img

    img = init

    img_size = img.shape[0]

    tile_x = np.tile(np.arange(img_size), (img_size, 1))
    tile_y = tile_x.T

    mean_x = np.sum(img * tile_x) / np.sum(img)
    mean_y = np.sum(img * tile_y) / np.sum(img)

    dist_mean_x = np.abs(mean_x - tile_x) * img
    dist_mean_y = np.abs(mean_y - tile_y) * img

    hypo = np.max(((dist_mean_x * dist_mean_x) + (dist_mean_y * dist_mean_y)))

    diff_mean_x = tile_x[img > 0].flatten() - mean_x
    diff_mean_y = tile_y[img > 0].flatten() - mean_y

    m = np.stack([diff_mean_x, diff_mean_y])

    decomposer = FastICA(2)
    decomposer.fit(m.T)
    Uica = decomposer.mixing_

    # print('ICA vectors')
    norms = np.sqrt((Uica ** 2).sum(axis=0))
    Uica = Uica / np.sqrt((Uica ** 2).sum(axis=0))
    if norms[0] > norms[1]:
        rotate = -np.arctan2(Uica[0, 0], Uica[1, 0])
    else:
        rotate = -np.arctan2(Uica[0, 1], Uica[1, 1])

    # represent between [-math.pi, math.pi]
    if rotate < -math.pi / 2:
        rotate += math.pi
    elif rotate > math.pi / 2:
        rotate -= math.pi

    # print('rotate: {:.2f} [deg]'.format(rotate * 360 / 2 / 3.14))

    aspect_ratio = max(norms) / min(norms)
    # print('aspect ratio: {:.2f}'.format(aspect_ratio))

    width = np.sqrt(hypo / (1 + aspect_ratio**2)) * 2 + 0.25
    # height = np.sqrt(hypo * aspect_ratio**2 / (1 + aspect_ratio**2)) * 2
    height = width * aspect_ratio

    # print('width: {} height: {}'.format(width, height))

    return mean_x, mean_y, height, aspect_ratio, rotate, img_size 
开发者ID:toshi-k,项目名称:kaggle-airbus-ship-detection-challenge,代码行数:61,代码来源:img2_coord_ica.py


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