Umap: Does UMAP accept a distance matrix as custom metric?

Created on 12 Apr 2018  路  9Comments  路  Source: lmcinnes/umap

Most helpful comment

As of version 0.2 onward it does yes. @LGro provided the code to enable this. If you set metric='precomputed' then you can pass a distance matrix rather than a dataset to the fit or fit_transform method.

All 9 comments

As of version 0.2 onward it does yes. @LGro provided the code to enable this. If you set metric='precomputed' then you can pass a distance matrix rather than a dataset to the fit or fit_transform method.

@VisuMap, in case you have trouble using that feature or any additional thoughts on the implementation, I'd be happy to discuss it.

Thanks for the info and kind offer. I guess I can wait till version 0.2 is officially released.

@VisuMap, it is released -- and should be available on PyPI and conda-forge. If it isn't working for you as intended please let me know.

@lmcinnes Will support for precomputed metrics soon make its way into 0.3dev?

@bccho It is already in 0.2, so yes it will continue to exist in 0.3dev.

@VisuMap, is this issue resolved or do you still have trouble accessing the feature?
If it is resolved, please consider closing the issue - thanks :)

As of version 0.2 onward it does yes. @LGro provided the code to enable this. If you set metric='precomputed' then you can pass a distance matrix rather than a dataset to the fit or fit_transform method.

And yet:

>>> U = umap.UMAP(metric='precomputed')
>>> XY = U.fit_transform(dm)
[鈥
ValueError: Metric is neither callable, nor a recognised string
>>> umap.__version__
0.3.0

@dawe, it seems like the lines around L1457 in the current master branch might fix your issue. Could you please try to build from master?
https://github.com/lmcinnes/umap/blob/ec860e9280dcd4a80c820c73c4cd5fb77cd59278/umap/umap_.py#L1453-L1462

Was this page helpful?
0 / 5 - 0 ratings