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


Python t_sne.trustworthiness函数代码示例

本文整理汇总了Python中sklearn.manifold.t_sne.trustworthiness函数的典型用法代码示例。如果您正苦于以下问题:Python trustworthiness函数的具体用法?Python trustworthiness怎么用?Python trustworthiness使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: test_trustworthiness_not_euclidean_metric

def test_trustworthiness_not_euclidean_metric():
    # Test trustworthiness with a metric different from 'euclidean' and
    # 'precomputed'
    random_state = check_random_state(0)
    X = random_state.randn(100, 2)
    assert_equal(trustworthiness(X, X, metric='cosine'),
                 trustworthiness(pairwise_distances(X, metric='cosine'), X,
                                 metric='precomputed'))
开发者ID:BranYang,项目名称:scikit-learn,代码行数:8,代码来源:test_t_sne.py

示例2: test_preserve_trustworthiness_approximately_with_precomputed_distances

def test_preserve_trustworthiness_approximately_with_precomputed_distances():
    # Nearest neighbors should be preserved approximately.
    random_state = check_random_state(0)
    X = random_state.randn(100, 2)
    D = squareform(pdist(X), "sqeuclidean")
    tsne = TSNE(n_components=2, perplexity=2, learning_rate=100.0, metric="precomputed", random_state=0, verbose=0)
    X_embedded = tsne.fit_transform(D)
    assert_almost_equal(trustworthiness(D, X_embedded, n_neighbors=1, precomputed=True), 1.0, decimal=1)
开发者ID:sofianehaddad,项目名称:scikit-learn,代码行数:8,代码来源:test_t_sne.py

示例3: test_trustworthiness

def test_trustworthiness():
    # Test trustworthiness score.
    random_state = check_random_state(0)

    # Affine transformation
    X = random_state.randn(100, 2)
    assert_equal(trustworthiness(X, 5.0 + X / 10.0), 1.0)

    # Randomly shuffled
    X = np.arange(100).reshape(-1, 1)
    X_embedded = X.copy()
    random_state.shuffle(X_embedded)
    assert_less(trustworthiness(X, X_embedded), 0.6)

    # Completely different
    X = np.arange(5).reshape(-1, 1)
    X_embedded = np.array([[0], [2], [4], [1], [3]])
    assert_almost_equal(trustworthiness(X, X_embedded, n_neighbors=1), 0.2)
开发者ID:BasilBeirouti,项目名称:scikit-learn,代码行数:18,代码来源:test_t_sne.py

示例4: test_fit_csr_matrix

def test_fit_csr_matrix():
    # X can be a sparse matrix.
    random_state = check_random_state(0)
    X = random_state.randn(100, 2)
    X[(np.random.randint(0, 100, 50), np.random.randint(0, 2, 50))] = 0.0
    X_csr = sp.csr_matrix(X)
    tsne = TSNE(n_components=2, perplexity=10, learning_rate=100.0, random_state=0, method="exact")
    X_embedded = tsne.fit_transform(X_csr)
    assert_almost_equal(trustworthiness(X_csr, X_embedded, n_neighbors=1), 1.0, decimal=1)
开发者ID:sofianehaddad,项目名称:scikit-learn,代码行数:9,代码来源:test_t_sne.py

示例5: test_preserve_trustworthiness_approximately

def test_preserve_trustworthiness_approximately():
    """Nearest neighbors should be preserved approximately."""
    random_state = check_random_state(0)
    X = random_state.randn(100, 2)
    for init in ('random', 'pca'):
        tsne = TSNE(n_components=2, perplexity=10, learning_rate=100.0,
                    init=init, random_state=0)
        X_embedded = tsne.fit_transform(X)
        assert_almost_equal(trustworthiness(X, X_embedded, n_neighbors=1), 1.0,
                            decimal=1)
开发者ID:HapeMask,项目名称:scikit-learn,代码行数:10,代码来源:test_t_sne.py

示例6: test_preserve_trustworthiness_approximately_with_precomputed_distances

def test_preserve_trustworthiness_approximately_with_precomputed_distances():
    # Nearest neighbors should be preserved approximately.
    random_state = check_random_state(0)
    for i in range(3):
        X = random_state.randn(100, 2)
        D = squareform(pdist(X), "sqeuclidean")
        tsne = TSNE(n_components=2, perplexity=2, learning_rate=100.0,
                    early_exaggeration=2.0, metric="precomputed",
                    random_state=i, verbose=0)
        X_embedded = tsne.fit_transform(D)
        t = trustworthiness(D, X_embedded, n_neighbors=1, metric="precomputed")
        assert t > .95
开发者ID:BranYang,项目名称:scikit-learn,代码行数:12,代码来源:test_t_sne.py

示例7: test_preserve_trustworthiness_approximately

def test_preserve_trustworthiness_approximately():
    # Nearest neighbors should be preserved approximately.
    random_state = check_random_state(0)
    n_components = 2
    methods = ['exact', 'barnes_hut']
    X = random_state.randn(50, n_components).astype(np.float32)
    for init in ('random', 'pca'):
        for method in methods:
            tsne = TSNE(n_components=n_components, init=init, random_state=0,
                        method=method)
            X_embedded = tsne.fit_transform(X)
            t = trustworthiness(X, X_embedded, n_neighbors=1)
            assert_greater(t, 0.9)
开发者ID:Lavanya-Basavaraju,项目名称:scikit-learn,代码行数:13,代码来源:test_t_sne.py

示例8: tsne

def tsne(D, medoids_df, dest_dir, fn):
    # Reproducing braincode/calculate_cluster_medoids_tSNE
    print('2D TSNE embedding plotting')
    tSNE = TSNE(n_components=2, perplexity=5,
                early_exaggeration=1.0, learning_rate=10.0,
                metric='precomputed', verbose=True, random_state=0)
    medoids2D = pd.DataFrame(tSNE.fit_transform(D), index=medoids_df.index)
    print('Trusty TSNE: %.2f' % trustworthiness(D.values,
                                                medoids2D.values,
                                                n_neighbors=5,
                                                precomputed=True))

    fig, ax = plt.subplots(nrows=1, ncols=1)
    cluster_scatter_plot(medoids2D[0], medoids2D[1],
                         labels=map(str, medoids2D.index),
                         ax=ax)
    plt.savefig(op.join(dest_dir, fn + '.singletons.tsne.png'))
开发者ID:strawlab,项目名称:braincode,代码行数:17,代码来源:dimred.py

示例9: test_preserve_trustworthiness_approximately

def test_preserve_trustworthiness_approximately():
    # Nearest neighbors should be preserved approximately.
    random_state = check_random_state(0)
    # The Barnes-Hut approximation uses a different method to estimate
    # P_ij using only a number of nearest neighbors instead of all
    # points (so that k = 3 * perplexity). As a result we set the
    # perplexity=5, so that the number of neighbors is 5%.
    n_components = 2
    methods = ['exact', 'barnes_hut']
    X = random_state.randn(100, n_components).astype(np.float32)
    for init in ('random', 'pca'):
        for method in methods:
            tsne = TSNE(n_components=n_components, perplexity=50,
                        learning_rate=100.0, init=init, random_state=0,
                        method=method)
            X_embedded = tsne.fit_transform(X)
            T = trustworthiness(X, X_embedded, n_neighbors=1)
            assert_almost_equal(T, 1.0, decimal=1)
开发者ID:AlexandreAbraham,项目名称:scikit-learn,代码行数:18,代码来源:test_t_sne.py


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