pyGAM icon indicating copy to clipboard operation
pyGAM copied to clipboard

Unclear about documentation for `generate_X_grid`?

Open yzjing opened this issue 5 years ago • 2 comments

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 avatar Apr 11 '19 17:04 yzjing

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.

yzjing avatar Apr 11 '19 20:04 yzjing

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

arose13 avatar Apr 17 '19 23:04 arose13