loess
loess copied to clipboard
Goes in infitie loop with some data
It's all in the title, with this simple data the script never stops. Am I missing something her e?
import Loess from "loess";
const data = {
x: [
19815, 19810, 19809, 19805, 19801, 19798, 19785, 19782, 19780, 19760, 19760,
19760, 19725,
],
y: [0.5, 1, 1, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5],
w: [
2265025, 3904576, 2253001, 4108729, 1236544, 4511376, 138532900, 1234321,
1806336, 1838736, 1838736, 1838736, 1188100,
],
};
const loessOptions = {};
const model = new Loess(data, loessOptions);
const fit = model.predict();
I've figured this one out @exebetche --
Math.js median operation hangs on NaN inputs: https://github.com/josdejong/mathjs/issues/1214
I just stepped through the repo and verified this is what is triggered in your case.
One solution is to upgrade the dependency of math.js, but I don't have enough time to debug why exactly they're nan in the first place...
Adding a patch here https://github.com/yongjun21/loess/issues/11
(but really the solution should be to make mathjs a peer dependency with version > 5.1.1