Skip to content

Instantly share code, notes, and snippets.

@josef-pkt
Created January 30, 2019 00:50
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save josef-pkt/29ad2116e9af0864e5100ded89efe1f5 to your computer and use it in GitHub Desktop.
Save josef-pkt/29ad2116e9af0864e5100ded89efe1f5 to your computer and use it in GitHub Desktop.
Basic GAM example with formula after merge
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Simply-Adi
Copy link

Hello, thanks for this valuable resource on how to use GAM in Python. I would like to know how I should specify knot locations.
I tried bs.knot_kwds={'knots':(num1,num2)}
It runs without error. But, is this the correct way?

@josef-pkt
Copy link
Author

The docstring says list of dict, because splines could have several variables and we need several splines. Try brackets [ ] around the dict.

You can inspect the bsplines instance to see how the knots where set.
Note: in Bsplines everything is in list of splines, e.g. from above bs = BSplines(x_spline, df=[12, 10], degree=[3, 3])

AFAICS, [s.knots for s in bs.smoothers] should show the knots for each univariate bspline.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment