dswah / pyGAM

[HELP REQUESTED] Generalized Additive Models in Python
https://pygam.readthedocs.io
Apache License 2.0
862 stars 159 forks source link

Unclear about documentation for `generate_X_grid`? #240

Open yzjing opened 5 years ago

yzjing commented 5 years ago

if term is >= 0, we generate n samples per feature, which results in n^deg samples, where deg is the degree of the interaction of the term

n (int, optional) – number of data points to create

I'm finding this a little unclear. Are the n samples chosen randomly? What is their meaning?

Example:

i = 0
XX = gam_kudos.generate_X_grid(term=i,n=100)
plt.plot(gam_kudos.partial_dependence(term=i, X=XX))

The above code generates the following plot. download I know that my _i_th feature is bound between [0,1], and the response variable is bound between [-6, 10]. This leaves me confused with this plot - what is the meaning of the x and y axis?

Am I missing something here? I sincerely appreciate any help.

yzjing commented 5 years ago

Update: after some more checking I think the problem comes from the code:

i = 0
XX = gam_kudos.generate_X_grid(term=i,n=100)
plt.plot(gam_kudos.partial_dependence(term=i, X=XX))

print(XX[:,0]) array([0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]) For some reason it doesn't pick up the range of my _i_th feature.

arose13 commented 5 years ago

could you quickly check which term is your intercept? (Just in case it is an easy fix)