Skip to content

Isomap doesn't actually support NearestNeighbors as input to .fit #13596

Closed

Description

@thatsmesasha

Description

Documentation for Isomap at https://scikit-learn.org/stable/modules/generated/sklearn.manifold.Isomap.html#sklearn.manifold.Isomap says I can provide NearestNeighbors object to .fit function. However it doesn't. It throws the error expecting 2D array.
Looking at the source code, I don't see any checks for the type of X data, just if it's a 2D array.
I'm using approach of NN + Isomap because NearestNeighbors supports callable metrics, unlike Isomap.

Expected Results

No error is thrown.

Actual Results

ValueError: Expected 2D array, got scalar array instead:
array=NearestNeighbors(algorithm='auto', leaf_size=30,
         metric=<function isomap_distance at 0x7fa0638c9488>,
         metric_params=None, n_jobs=None, n_neighbors=5, p=2, radius=1.0).
Reshape your data either using array.reshape(-1, 1) if your data has a single feature or array.reshape(1, -1) if it contains a single sample.

Versions

System:
python: 3.6.7 (default, Oct 22 2018, 11:32:17) [GCC 8.2.0]
executable: /usr/bin/python3
machine: Linux-4.14.79+-x86_64-with-Ubuntu-18.04-bionic

BLAS:
macros: SCIPY_MKL_H=None, HAVE_CBLAS=None
lib_dirs: /usr/local/lib
cblas_libs: mkl_rt, pthread

Python deps:
pip: 19.0.3
setuptools: 40.9.0
sklearn: 0.20.3
numpy: 1.14.6
scipy: 1.1.0
Cython: 0.29.6
pandas: 0.22.0

Activity

  1. jnothman commented on Apr 9, 2019

    @jnothman
    Member

    I suspect you're right and the documentation is outdated, but please provide a fully reproducible code snippet to make it easy to confirm

  2. TomDLT commented on Apr 9, 2019

    @TomDLT
    Member

    I also noticed this issue in #10463 (see issue 3).
    It is (partially) fixed in #10482 as I removed the call to check_array in Isomap._fit_transform.

  3. TomDLT commented on Sep 18, 2019

    @TomDLT
    Member

    Fixed in #10482

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions