lmcinnes / umap

Uniform Manifold Approximation and Projection
BSD 3-Clause "New" or "Revised" License
7.45k stars 808 forks source link

cannot set init parameter to pca #994

Open mayuris25 opened 1 year ago

mayuris25 commented 1 year ago

I have installed umap-learn==0.5.3 with python 3.10

% pip list 
Package         Version
--------------- -------
colorama        0.4.6
joblib          1.2.0
llvmlite        0.39.1
numba           0.56.3
numpy           1.23.4
pandas          2.0.0
pip             22.3.1
pynndescent     0.5.8
python-dateutil 2.8.2
pytz            2023.3
scikit-learn    1.1.3
scipy           1.9.3
setuptools      65.5.1
six             1.16.0
threadpoolctl   3.1.0
tqdm            4.64.1
tzdata          2023.3
umap-learn      0.5.3
wheel           0.38.4

tried to run a simple umap conversion with init parameter set to 'pca'

    import umap as umap
    from umap import UMAP
    umap_nd = UMAP(n_components=components,
                   init='pca',
                   random_state=42,
                   n_neighbors=n_neighbors,
                   min_dist=min_dist
        )
    print(umap.__version__)
    proj_nd = umap_nd.fit(data_df.values)

the print output is saying its version 0.5.3 but it is giving error as below (sharing snippet)

    proj_nd = umap_nd.fit(data_df.values)
  File "/home/.pyenv/versions/anaconda3-5.3.1/envs/project-p/lib/python3.10/site-packages/umap/umap_.py", line 2290, in fit
    self._validate_parameters()
  File "/home/versions/anaconda3-5.3.1/envs/project-p/lib/python3.10/site-packages/umap/umap_.py", line 1704, in _validate_parameters
    raise ValueError('string init values must be "spectral" or "random"')
ValueError: string init values must be "spectral" or "random" 
jlmelville commented 1 year ago

The PCA initialization option isn't in the 0.5.3 release (which came out last year).

mayuris25 commented 1 year ago

I see, can I know what is the latest release version? because in the UMAP API guide for latest version it mentions 'pca' and 'twspectral' as options

jlmelville commented 1 year ago

The most recent release is 0.5.3. If you are looking at https://umap-learn.readthedocs.io/en/latest/api.html that seems to refer to the current state of the master branch of this repo.

If you want to know the options available for whatever version of UMAP you have installed is then this should work:

import umap
help(umap.UMAP)