Skip to content
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

Screen freeze #28

Open
bumbeishvili opened this issue Mar 31, 2020 · 2 comments
Open

Screen freeze #28

bumbeishvili opened this issue Mar 31, 2020 · 2 comments

Comments

@bumbeishvili
Copy link

bumbeishvili commented Mar 31, 2020

I am not sure if this counts as an issue.

I have a fairly low, 12 data points (last 12 days covid19 new cases in Europe)

data = [
  {"x":1,"y":18539},{"x":2,"y":20695},{"x":3,"y":21848},
  {"x":4,"y":19121},{"x":5,"y":23501},{"x":6,"y":28724},
  {"x":7,"y":28061},{"x":8,"y":36222},{"x":9,"y":37756},
  {"x":10,"y":38212},{"x":11,"y":31629},{"x":12,"y":32282}
]

Screen Shot 2020-03-31 at 22 42 15

and I am trying to fit 3 order polynomial regression

polynomialRegression = d3.regressionPoly()
   .x(d => d.x)
   .y(d => d.y)
   .order(3);

And it freezes the screen indefinitely.

Here is an observable notebook where this issue is reproduced (just uncomment the first line)
https://observablehq.com/d/69dd1849304db49f

Question: Is it normal for this function to behave like this when we have such a small dataset?

@Fil
Copy link

Fil commented Nov 20, 2020

You can fix this particular notebook by dividing y:

polynomialRegression = d3.regressionPoly()
  .x(d => d.x)
  .y(d => d.y / 1000)
  .order(3);

I've noticed a similar issue if the value of x is huge (for example, working with timestamps). Rescaling the whole dataset to a "reasonable" range of values is often necessary. This could (should?) probably be done internally.

@bumbeishvili
Copy link
Author

Looks like this fixes it, thank you very much.
Screen Shot 2020-11-20 at 6 19 23 PM

This could (should?) probably be done internally.

This would be nice

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

2 participants