Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/source/zero-code-change-limitations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,9 @@ TSNE

- If ``n_components`` is not ``2``.
- If ``init`` is an array.
- If ``metric`` isn't one of the supported metrics ( ``"l2"``, ``"euclidean"``,
``"sqeuclidean"``, ``"cityblock"``, ``"l1"``, ``"manhattan"``,
``"minkowski"``, ``"chebyshev"``, ``"cosine"``, ``"correlation"``).

Additionally, the following fitted attributes are currently not computed:

Expand Down
38 changes: 20 additions & 18 deletions python/cuml/cuml/manifold/t_sne.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,20 @@ cdef extern from "cuml/manifold/tsne.h" namespace "ML" nogil:
float* kl_div) except +


_SUPPORTED_METRICS = {
"l2": DistanceType.L2SqrtExpanded,
"euclidean": DistanceType.L2SqrtExpanded,
"sqeuclidean": DistanceType.L2Expanded,
"cityblock": DistanceType.L1,
"l1": DistanceType.L1,
"manhattan": DistanceType.L1,
"minkowski": DistanceType.LpUnexpanded,
"chebyshev": DistanceType.Linf,
"cosine": DistanceType.CosineExpanded,
"correlation": DistanceType.CorrelationExpanded
}


class TSNE(Base,
InteropMixin,
CMajorInputTagMixin,
Expand Down Expand Up @@ -314,6 +328,9 @@ class TSNE(Base,
if not (isinstance(model.init, str) and model.init in ("pca", "random")):
raise UnsupportedOnGPU(f"`init={model.init!r}` is not supported")

if not (isinstance(model.metric, str) and model.metric in _SUPPORTED_METRICS):
raise UnsupportedOnGPU(f"`metric={model.metric!r}` is not supported")

params = {
"n_components": model.n_components,
"perplexity": model.perplexity,
Expand Down Expand Up @@ -719,25 +736,10 @@ class TSNE(Base,
elif self.init.lower() == 'pca':
params.init = TSNE_INIT.PCA

# metric
metric_parsing = {
"l2": DistanceType.L2SqrtExpanded,
"euclidean": DistanceType.L2SqrtExpanded,
"sqeuclidean": DistanceType.L2Expanded,
"cityblock": DistanceType.L1,
"l1": DistanceType.L1,
"manhattan": DistanceType.L1,
"minkowski": DistanceType.LpUnexpanded,
"chebyshev": DistanceType.Linf,
"cosine": DistanceType.CosineExpanded,
"correlation": DistanceType.CorrelationExpanded
}

if self.metric.lower() in metric_parsing:
params.metric = metric_parsing[self.metric.lower()]
if (metric := _SUPPORTED_METRICS.get(self.metric, None)) is not None:
params.metric = metric
else:
raise ValueError("Invalid value for metric: {}"
.format(self.metric))
raise ValueError(f"Invalid value for metric: {self.metric}")

if self.metric_params is None:
params.p = <float> 2.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -432,37 +432,18 @@
- "sklearn.linear_model.tests.test_sparse_coordinate_descent::test_sparse_lasso_not_as_toy_dataset[csc_array]"
- "sklearn.linear_model.tests.test_sparse_coordinate_descent::test_sparse_lasso_not_as_toy_dataset[csc_matrix]"
- "sklearn.manifold.tests.test_t_sne::test_accessible_kl_divergence"
- "sklearn.manifold.tests.test_t_sne::test_bad_precomputed_distances[D0-.* square distance matrix-barnes_hut-asarray]"
- "sklearn.manifold.tests.test_t_sne::test_bad_precomputed_distances[D0-.* square distance matrix-barnes_hut-csr_array]"
- "sklearn.manifold.tests.test_t_sne::test_bad_precomputed_distances[D0-.* square distance matrix-barnes_hut-csr_matrix]"
- "sklearn.manifold.tests.test_t_sne::test_bad_precomputed_distances[D0-.* square distance matrix-exact-asarray]"
- "sklearn.manifold.tests.test_t_sne::test_bad_precomputed_distances[D1-.* positive.*-barnes_hut-asarray]"
- "sklearn.manifold.tests.test_t_sne::test_bad_precomputed_distances[D1-.* positive.*-barnes_hut-csr_array]"
- "sklearn.manifold.tests.test_t_sne::test_bad_precomputed_distances[D1-.* positive.*-barnes_hut-csr_matrix]"
- "sklearn.manifold.tests.test_t_sne::test_bad_precomputed_distances[D1-.* positive.*-exact-asarray]"
- "sklearn.manifold.tests.test_t_sne::test_bh_match_exact"
- "sklearn.manifold.tests.test_t_sne::test_binary_perplexity_stability"
- "sklearn.manifold.tests.test_t_sne::test_exact_no_precomputed_sparse[csr_array]"
- "sklearn.manifold.tests.test_t_sne::test_exact_no_precomputed_sparse[csr_matrix]"
- "sklearn.manifold.tests.test_t_sne::test_fit_transform_csr_matrix[csr_array-barnes_hut]"
- "sklearn.manifold.tests.test_t_sne::test_fit_transform_csr_matrix[csr_array-exact]"
- "sklearn.manifold.tests.test_t_sne::test_high_perplexity_precomputed_sparse_distances[csr_array]"
- "sklearn.manifold.tests.test_t_sne::test_high_perplexity_precomputed_sparse_distances[csr_matrix]"
- "sklearn.manifold.tests.test_t_sne::test_max_iter_used"
- "sklearn.manifold.tests.test_t_sne::test_n_iter_without_progress"
- "sklearn.manifold.tests.test_t_sne::test_non_positive_computed_distances"
- "sklearn.manifold.tests.test_t_sne::test_pca_initialization_not_compatible_with_precomputed_kernel"
- "sklearn.manifold.tests.test_t_sne::test_pca_initialization_not_compatible_with_sparse_input[csr_array]"
- "sklearn.manifold.tests.test_t_sne::test_pca_initialization_not_compatible_with_sparse_input[csr_matrix]"
- "sklearn.manifold.tests.test_t_sne::test_preserve_trustworthiness_approximately[pca-barnes_hut]"
- "sklearn.manifold.tests.test_t_sne::test_preserve_trustworthiness_approximately[pca-exact]"
- "sklearn.manifold.tests.test_t_sne::test_preserve_trustworthiness_approximately[random-barnes_hut]"
- "sklearn.manifold.tests.test_t_sne::test_preserve_trustworthiness_approximately[random-exact]"
- "sklearn.manifold.tests.test_t_sne::test_preserve_trustworthiness_approximately_with_precomputed_distances"
- "sklearn.manifold.tests.test_t_sne::test_sparse_precomputed_distance[csr_array]"
- "sklearn.manifold.tests.test_t_sne::test_sparse_precomputed_distance[csr_matrix]"
- "sklearn.manifold.tests.test_t_sne::test_sparse_precomputed_distance[lil_array]"
- "sklearn.manifold.tests.test_t_sne::test_sparse_precomputed_distance[lil_matrix]"
- "sklearn.manifold.tests.test_t_sne::test_tsne_n_jobs[barnes_hut]"
- "sklearn.manifold.tests.test_t_sne::test_tsne_n_jobs[exact]"
- "sklearn.manifold.tests.test_t_sne::test_tsne_perplexity_validation[20]"
Expand Down
Loading