Questions tagged [pygam]

pyGAM is a package for building Generalized Additive Models in Python, it IS NOT for the GUI package [pygame].

12 questions
3
votes
1 answer

partial_dependence() got an unexpected keyword argument 'feature' for a python generalized additive model. How do I fix it?

I’m attempting to make a generalized additive model for some ocean data. My code is the following: from pygam import LinearGAM from pygam import LogisticGAM import pandas as pd import numpy as np import matplotlib.pyplot as plt import seaborn as…
April
  • 31
  • 2
2
votes
0 answers

Python package of GAM with functions of tensor product and thin plate regression spline

I'm searching for a python package of GAM model with the functions of tensor product and thin plate spline like mgcv in R. Specifically, like ti(a, b, bs = c('tp','tp')) by mgcv. PyGAM has tensor product function te(), however it doesn't seem to…
Pablo34
  • 21
  • 1
2
votes
2 answers

ModuleNotFoundError: No module named 'pygam'

I'm trying to execute a python script which pygam ( from pygam import LogisticGAM, LinearGAM ). when I'm trying to execute this script  I have this error: ModuleNotFoundError: No module named 'pygam' The problem that pygam is installed with both…
el abed houssem
  • 350
  • 1
  • 7
  • 16
1
vote
1 answer

Calculation of Derivatives in pyGAM

I would like to calculate the derivative of a fitted GAM model a at specific points in pyGAM. The model contains only spline terms, such that it should be effectively a BSpline. Indeed, use of pygam.utils.b_spline_basis gives a matrix, which I can…
chris1992
  • 41
  • 1
  • 8
1
vote
2 answers

How to turn a pygam model into a SciPy BSpline

I would like to get the best of two worlds: Scipy and pygam. Specifically, I want to penalise the third derivative of my data using a custom pygam penalty function, and then I would like to use the result as a Scipy BSpline. The latter allows for…
chris1992
  • 41
  • 1
  • 8
1
vote
0 answers

Linear GAM in python

I need to copy this plot using pygam library. I create GAM using the following code: gam = LinearGAM(s(0, n_splines=5, spline_order=4) + s(1, n_splines=9) + f(2)) gam = gam.gridsearch(X, y, lam = lams) Unfortunately, in my case the plots are the…
Bruh
  • 25
  • 7
1
vote
1 answer

How to extract intercept parameter from python pygam.LinearGAM

I am looking to extract the fitted parameter from a model fit with pygam. Here is a reproducible example. from pygam import LinearGAM, s, f from pygam.datasets import wage X, y = wage() gam = LinearGAM(s(0) + s(1) + f(2)).fit(X, y) Here are few…
jmuhlenkamp
  • 2,102
  • 1
  • 14
  • 37
0
votes
0 answers

I fitted a Generalized Additive Model. How can I implement it in sql

I fitted a GAM model in python using the codes below. gam = LinearGAM(s(0, n_splines=5)).gridsearch(x[:,None],y) and gam.coef_ gives me this array. array([ 0.33231444, -0.0088823 , -0.06823895, -0.07444204, -0.10057209, …
Grant
  • 1
0
votes
0 answers

How can you use sklearn cross-validation functions (eg BayesSearchCV) to find the optimal penalty term in pyGAM?

The problem I'm having is that with pyGAM, the class with the fit method (e.g. LinearGAM) does not have an argument which species the penalty term. Instead you need to specify lam as an argument to your individual splines (e.g. s(0, lam=0.1)). This…
tobmo
  • 25
  • 3
0
votes
0 answers

LinearGAM object plotting multiple regression lines

I am trying to plot a non-linear line of best fit on top of a scatterplot, but it prints multiple lines, no matter what spline parameters I use. I have no idea what may be going on - any ideas? Thanks! def plot_gene_pseudotime(adata, gene_name,…
Carmen Sandoval
  • 2,266
  • 5
  • 30
  • 46
0
votes
1 answer

pyGAM `y data is not in domain of logit link function`

I'm trying to find to what degree the chemical properties of a wine dataset influence the quality property of the dataset. The error: ValueError: y data is not in domain of logit link function. Expected domain: [0.0, 1.0], but found [3.0,…
Jonathan Woollett-light
  • 2,813
  • 5
  • 30
  • 58
0
votes
0 answers

NameError in ipython-input with generate_X_grid

import pandas as pd from pygam import LogisticGAM from sklearn.datasets import load_breast_cancer #load the breast cancer data set data = load_breast_cancer() # keep first 6 features only df = pd.DataFrame(data.data,…