Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Jezzamonn opened this issue Dec 15, 2015 · 4 comments
Closed

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

Jezzamonn opened this issue Dec 15, 2015 · 4 comments

Comments

@Jezzamonn
Copy link

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.

@soupault
Copy link

soupault commented Feb 4, 2016

I confirm. Error is raised for both method='ltsa' (see @Jezzamonn log) and method='hessian' (see log below). Everything else works fine.

Traceback (most recent call last):
  File "test.py", line 46, in <module>
    method=method).fit_transform(X)
  File "/usr/lib/python3.5/site-packages/sklearn/manifold/locally_linear.py", line 652, in fit_transform
    self._fit_transform(X)
  File "/usr/lib/python3.5/site-packages/sklearn/manifold/locally_linear.py", line 623, in _fit_transform
    random_state=random_state, reg=self.reg)
  File "/usr/lib/python3.5/site-packages/sklearn/manifold/locally_linear.py", line 327, in locally_linear_embedding
    Gi -= Gi.mean(0)
TypeError: Cannot cast ufunc subtract output from dtype('float64') to dtype('int64') with casting rule 'same_kind'

jakevdp added a commit to jakevdp/scikit-learn that referenced this issue Feb 4, 2016
@jakevdp
Copy link
Member

jakevdp commented Feb 4, 2016

I added a fix in #6282

@soupault
Copy link

soupault commented Feb 5, 2016

@jakevdp thanks a lot!

@amueller
Copy link
Member

amueller commented Oct 7, 2016

Fixed in #6282

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants