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

Improve performance between lambda changes #4

Open
jxjj opened this issue Jul 29, 2021 · 0 comments
Open

Improve performance between lambda changes #4

jxjj opened this issue Jul 29, 2021 · 0 comments

Comments

@jxjj
Copy link
Contributor

jxjj commented Jul 29, 2021

Random thoughts for later:

  • Once calculated, save the singular value decomposition (svd) of the basis matrix, U, sigmaVector,V and maybe U'*y. Then we should be able to recalc betas more quickly.
  • Provide an function for updating lambda.

Sticking with a functional approach, maybe the spline object returned from a smoothing spline, also includes _meta information for recalculating and an update or with function (or some other word that might be more suggestive that a new spline is returned rather than the original spline is mutated?)

const spline = await simpleSmoothingSpline(data, { lambda: 1 });
// first run so a bit slower, but work is saved to _meta

const newSpline = await spline.update({ lambda: 2 })
// faster since we can reuse previous work

Where spline might look like:

{
	points, // spline points
	fn,     // function to generate spline y for given x
	_meta: {
		type: 'smoothing'
		work: {
			svd,
			Utranspose,
			y,
		}
	update, // can use _meta.work to update and return a new spline object
}

Or, rather than moving state around in objects, move (back) to a OO implementation?

Possible OO API:

const spline = new SimpleSmoothingSpline(data, { lambda: 1 });
const points = await spline.getPoints();
// first run so a bit slower, but work is saved

const newPoints = await spline.update({ lambda: 1000 }).getPoints();
// faster since we can reuse previous work
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

1 participant