I have been trying to find a Python alternative for fitting a GAM of penalised spline terms. I have had a look at both pyGAM and statsmodels but it seems that both do not include the feature which I am looking for.
I would like to include splines in my model which support a categorical by-variable.
Say for example I have data of temperature measurements. I might have a column called "temperature" which contains the measured temperature as floats and another column "instrument" which gives the thermometer I used for the measurement as a categorical variable (either as a string of the name of the instrument or a integer categorical label). If I now want to fit a model where splines are fitted separately for each instrument I understand that I can do this in R using
s(temperature,by=as.factor(instrument),k=80, bs="ps")
for example.
In fact, if I had another column "air pressure", I could even model an interaction term between "temperature" and "air pressure", with "instrument" as a categorical by-variable.
Does anyone know if this is somehow possible in Python? Maybe I have misread pyGAM/statsmodels.