I am using UMAP for clustering. However I can't find any information about methods to fine tune n_components parameter (which is very important). As good as I understand I can't use explained variance as for PCA. So what are alternatives?


1 Answer 1


There is a UMAP parameter called n_component, which is the dimension in output (1D, 2D, etc.). https://umap-learn.readthedocs.io/en/latest/parameters.html#n-components

UMAP is not like PCA in terms of n_components: In fact, all the initial dimensions (=initial data having m features) are projected to a lower-dimensional space (=n components).

The UMAP axes don't have the same meaning as the PCA axes: UMAP represents a relative space of probabilities, whereas PCA axes represent the main features' abundance of variation.

As a consequence, you just have to choose n_components based on data complexity and volume.

In most cases, n_components = 2 is the best option because it is easier to read a 2D map than a 1D or 3D map or more. Very simple cases with few clusters would be better with n_components = 1. In complex cases with many features, n_components = 3 or more might be better.

Note that for output with n_components >=3, you can extract 2D views from it to see clusters from different angles.

Here is a cool website explaining UMAP interactively: https://pair-code.github.io/understanding-umap/


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.