Skip to content

Locally Linear Embedding manifold doesn't work with integer inputs #6033

@Jezzamonn

Description

@Jezzamonn

An error occurs when you try to use manifold.LocallyLinearEmbedding with an integer array as the input if you have certain values of the method parameter. I'm running the latest version of scikit-learn (I got this error, updated through conda, and the error still occurs).

Traceback (most recent call last):
  File "C:/Users/jswanson/Downloads/plot_compare_methods.py", line 63, in <module>
    method=method).fit_transform(X)
  File "C:\Users\jswanson\AppData\Local\Continuum\Anaconda3\lib\site-packages\sklearn\manifold\locally_linear.py", line 652, in fit_transform
    self._fit_transform(X)
  File "C:\Users\jswanson\AppData\Local\Continuum\Anaconda3\lib\site-packages\sklearn\manifold\locally_linear.py", line 623, in _fit_transform
    random_state=random_state, reg=self.reg)
  File "C:\Users\jswanson\AppData\Local\Continuum\Anaconda3\lib\site-packages\sklearn\manifold\locally_linear.py", line 476, in locally_linear_embedding
    Xi -= Xi.mean(0)
TypeError: Cannot cast ufunc subtract output from dtype('float64') to dtype('int64') with casting rule 'same_kind'

For some code that demonstrates the error, you can run the example here http://scikit-learn.org/stable/auto_examples/manifold/plot_compare_methods.html, but cast the data to int64 first. You can do this by inserting the following line below line 38

X = (1000 * X).astype('int64')

By glancing through similar issues, I think this is caused by an update to numpy.

I'll just work around the issue by casting my data to floats, but I thought I should still bring it up.

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