Screen freeze
Opened this issue · 2 comments
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}
]
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?
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.