Test other special discrete metrics
@@ -790,6 +790,43 @@ def test_metric_supervised_umap_trustworthiness():
)
+def test_metric_supervised_umap_trustworthiness():
+ data, labels = datasets.make_blobs(50, cluster_std=0.5, random_state=42)
+ embedding = UMAP(n_neighbors=10,
+ min_dist=0.01,
+ target_metric='l1',
+ target_weight=0.8,
+ n_epochs=200,
+ random_state=42).fit_transform(
+ data, labels
+ )
+ trust = trustworthiness(data, embedding, 10)
+ assert_greater_equal(
+ trust,
+ 0.95,
+ "Insufficiently trustworthy embedding for" "blobs dataset: {}".format(trust),
+ )
+
+
+def test_string_metric_supervised_umap_trustworthiness():
+ data, labels = datasets.make_blobs(50, cluster_std=0.5, random_state=42)
+ labels = np.array(["this", "that", "other"])[labels]
+ embedding = UMAP(n_neighbors=10,
+ min_dist=0.01,
+ target_metric='string',
+ target_weight=0.8,
+ n_epochs=200,
+ random_state=42).fit_transform(
+ data, labels
+ )
+ trust = trustworthiness(data, embedding, 10)
+ assert_greater_equal(
+ trust,
+ 0.95,
+ "Insufficiently trustworthy embedding for" "blobs dataset: {}".format(trust),
+ )
+
+
def test_discrete_metric_supervised_umap_trustworthiness():
data, labels = datasets.make_blobs(50, cluster_std=0.5, random_state=42)
embedding = UMAP(n_neighbors=10,
@@ -808,6 +845,25 @@ def test_discrete_metric_supervised_umap_trustworthiness():
)
+def test_string_metric_supervised_umap_trustworthiness():
+ data, labels = datasets.make_blobs(50, cluster_std=0.5, random_state=42)
+ labels = (labels ** 2) + 2 * labels
+ embedding = UMAP(n_neighbors=10,
+ min_dist=0.01,
+ target_metric='count',
+ target_weight=0.8,
+ n_epochs=200,
+ random_state=42).fit_transform(
+ data, labels
+ )
+ trust = trustworthiness(data, embedding, 10)
+ assert_greater_equal(
+ trust,
+ 0.95,
+ "Insufficiently trustworthy embedding for" "blobs dataset: {}".format(trust),
+ )
+
+
def test_umap_trustworthiness_on_iris():
data = iris.data
embedding = UMAP(n_neighbors=10, min_dist=0.01, random_state=42).fit_transform(data)
