-
Notifications
You must be signed in to change notification settings - Fork 787
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
RecursionError #99
Comments
This is an odd issue that I never fully tracked down -- it seems to depend
on an odd data distribution (often involving duplicate points). What is
happening is that the random projection tree recursively splits the data
into smaller and smaller pieces. Apparently we hit the recursion limit. In
practice we should expect the data to be split approximately in half each
time, so the tree depth should be expected to be around log_2(200000) ~ 18.
Somehow, instead we have a tree depth that has exceeded 10000, so the
splitting is working very strangely.
One potential solution is to add a small amount of noise to the data
(smaller than the smallest distances between non-identical samples). This
may work around the problem for you.
…On Thu, Aug 2, 2018 at 3:59 AM Samet Dumankaya ***@***.***> wrote:
Hi, thanks for the great package.
I have a dataset which has 200000 rows and 15 columns. I tried to apply
UMAP as following
embedding = umap.UMAP(n_neighbors=5, min_dist=0.3,
metric='correlation').fit_transform(data)
After 10 seconds, I got following exceptions :
- RecursionError: maximum recursion depth exceeded while calling a
Python object
- return make_angular_tree(data, indices, rng_state, leaf_size)
SystemError: CPUDispatcher(<function angular_random_projection_split
at 0x000001C8260D6378>)
returned a result with an error set
I set the system recursion limit to 10000 as below and tried again but
then python exited with a code like -143537645 meaning exited with error.
sys.setrecursionlimit(10000)
Is there any solution, workaround or anything I can do for this problem?
Thanks.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#99>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/ALaKBS-V8cELGXnEGgpvSLI5AnpHLlZcks5uMrFLgaJpZM4Vrz0B>
.
|
I just ran into the same issue, and indeed removing duplicate points did solved the problem. I used a simple workaround, but I am not sure if it is justified to do so or it actually affects the method: can we safely remove the duplicates, embed the unique points and then reconstruct the original array by re-duplicating the embeddings? My intuitition of the technique is that if N points are exactly the same we could safely work with only one of them and map all of them to the result, but I would like confirmation from someone who actually understands all the math involved. If that assumption is correct, I guess I can start working in a pull request adding the fix. |
It is not necessarily ideal. I really need to understand better how
duplicate points are resulting in a recursion error to be honest. My
understanding is that they should not, but perhaps I have missed a corner
case in the implementation somewhere.
…On Mon, Aug 27, 2018 at 4:23 AM Diego Vicente ***@***.***> wrote:
I just ran into the same issue, and indeed removing duplicate points did
solved the problem. I used a simple workaround, but I am not sure if it is
justified to do so or it actually affects the method: can we safely remove
the duplicates, embed the unique points and then reconstruct the original
array by re-duplicating the embeddings?
My intuitition of the technique is that if N points are exactly the same
we could safely work with only one of them and map all of them to the
result, but I would like confirmation from someone who actually understands
all the math involved. If that assumption is correct, I guess I can start
working in a pull request adding the fix.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#99 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ALaKBc3AGRq8Su2qvfo5xiS1OTNMV_MHks5uU6yagaJpZM4Vrz0B>
.
|
I'm also having this problem. Adding an uncomfortably large amount of noise as a hack also works for me |
I think I really need a way to avoid the trees far "bad" data, although I
am not sure that NN-descent will do much better with it. Perhaps I'll try
to add a max depth to the trees and just accept whatever they give at a
certain depth. That might be uncomfortable computationally, but such is
life.
…On Tue, Sep 4, 2018 at 12:07 PM fistR ***@***.***> wrote:
I'm also having this problem. Adding an uncomfortably large amount of
noise as a hack also works for me
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#99 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ALaKBauNf4b4sDVeOvXkxw6l--SXy31Yks5uXqVLgaJpZM4Vrz0B>
.
|
Just an update, it seems that when it complains about recursion depth but does not crash out, the result gets funky. It is apparent in visualisation purposes. Im trying to track down what the problem vectors are as the amount of noise I need to add for it to work ruins the end result too |
I would be very interested to know a set of vectors that specifically cause
this problem. It's been a difficult issue to debug, or even to understand
to be honest. If you can use the messed up embedding to extract out the
actual causal vectors that would be a significant step and I would greatly
appreciate such information! Thanks for your patience and persistence in
working through this.
…On Wed, Sep 5, 2018 at 12:51 PM fistR ***@***.***> wrote:
Just an update, it seems that when it complains about recursion depth but
does not crash out, the result gets funky. It is apparent in visualisation
purposes. Im trying to track down what the problem vectors are as the
amount of noise I need to add for it to work ruins the end result too
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#99 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ALaKBVdeRdvjaVnbGNSD7nhUx6_vXGzPks5uYAEEgaJpZM4Vrz0B>
.
|
I encountered the same problem with 17.5M data points. I used euclidean distance and scaled the data during preprocessing... Does anyone have any ideas about this? Thanks! |
That's a lot of data points! I would check for duplicate data as that may
cause some issues for the random projection trees. Beyond that I'm not
entirely sure - -I've never been able to reliably reproduce the error to be
able to properly track down the issue.
…On Fri, Nov 16, 2018 at 1:49 PM Yizhou ***@***.***> wrote:
I encountered the same problem with 17.5M data points.
I used euclidean distance and scaled the data during preprocessing...
Here is the code:
X_scaled = preprocessing.scale(X)
fit = umap.UMAP(n_neighbors=20, min_dist=0.01, metric='euclidean',
init='random',n_epochs=500)
The same parameter setting works on the sampling data with 100K data
points.
Does anyone have any ideas about this?
Thanks!
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#99 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ALaKBRv0aiN48pvT2esx_BqBw-bjmYqJks5uvwizgaJpZM4Vrz0B>
.
|
I was receiving the same error and adding a small amount of noise did help. Thanks! |
@lmcinnes I attached you a 5000x100 numpy array that always makes UMAP crashes. |
Thanks @scharron, reproducing examples are very useful. I'll try to look ta this when I get a little more time. |
Experiencing the same issue. Removing duplicates solved my problem, and was fine for my visualization purposes. |
Same issue here |
I think some fixes to other issues may actually resolve this, so I'll try to roll out a patch release in the next few days that will hopefully solve this. |
Did you roll out your patch yet? |
I should have come in the last patch release -- if that didn't fix things
then there may be yet more deeper issues that remain elusive.
…On Wed, Apr 10, 2019 at 11:40 AM Malthe Karbo ***@***.***> wrote:
Did you roll out your patch yet?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#99 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ALaKBVTKchrOG5G7C8wmsyftMuhZizocks5vfgXugaJpZM4Vrz0B>
.
|
I have confirmed that @scharron's attached data causes a failure on the latest UMAP with The culprit seems to be the Lines 28 to 29 in 6a32f62
Set I suppose this could also be affecting the Euclidean and sparse versions of the projection split and just waiting for a dataset to trigger them. The downside of According to the numba docs, it's possible to opt in to a subset of the fast math settings, so that might be worth looking into. |
Thanks @jlmelville ! I will have to look into the details of what subset of |
I looked at trying out some subsets of Looking in more detail at this, the problem seems to arise because of checking float values for 0. There's a lot of it in Line 297 in 6a32f62
If that changes to Alternatively, is it the case that Lines 465 to 466 in 6a32f62
You can prevent the loop by bailing out by I was hoping to try out some of these solutions and submit a pr through |
Yes, the tree should never create nodes of size zero, so that is certainly part of the problem. I guess the question is where is the best place to catch this. Your observation that the The data contains a number of points that, while distinct and non-zero, are all scalar multiples of each other. Thus, they all lie on a line from the origin, and an angular hyperplane cannot possibly separate them. Ideally the Now, there are a few ways to fix this: we can fix the margin comparison, as you have done to handle issues with floats better (and make the similar required changes to the other splitting routines); we can go after the root of the problem (a bad hyperplane; all zeros for the hyperplane vector in all the cases I believe), and if that occurs then just automate the random splitting; finally we could take the other option you suggest and catch splits that result in zero points in one side and insert a forced random partitioning into two nodes there. The first way should work well enough, and seems mostly clean aside from the catch that we'll very occasionally mis-assign points that are very close to the hyperplane margin. The second approach gets to the heart of the actual issue, but still requires actually detecting an all zero hyperplane (up to float tolerances). The third option is probably the most robust in that if there are other reasons why the split can go astray (and there may be) it will still catch them. It is a more awkward fix to implement however. To be honest I'm happiest with option 1 (fix the margin comparison). It will get the job done with the least amount of fuss. I'll see what the issues with pynndescent are -- the tests are all a bit new, so it could well be errors in the testing more than anything. |
#99: port recursion error fix from pynndescent
The latest fixes merged on master seems to fix the problem here to my tests on ~100k points |
That's greta news. I'll try to put out a release soon.
…On Sun, Apr 28, 2019 at 2:17 AM Radamés Ajna ***@***.***> wrote:
The latest fixes merged on master seems to fix the problem here to my
tests on ~100k points (n_neighbors=20, metric='cosine', min_dist=0.4
,init='random', verbose=2) !
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
<#99 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AC3IUBLZUESA4KABDSMVPKTPSU6OFANCNFSM4FNPHUAQ>
.
|
Hi, thanks for the great package.
I have a dataset which has 200000 rows and 15 columns. I tried to apply UMAP as following
embedding = umap.UMAP(n_neighbors=5, min_dist=0.3, metric='correlation').fit_transform(data)
After 10 seconds, I got following exceptions :
SystemError: CPUDispatcher(<function angular_random_projection_split at 0x000001C8260D6378>)
returned a result with an error set
I set the system recursion limit to 10000 as below and tried again but then python exited with a code like -143537645 meaning exited with error.
sys.setrecursionlimit(10000)
Is there any solution, workaround or anything I can do for this problem?
Thanks.
The text was updated successfully, but these errors were encountered: