dswah / pyGAM

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

Updated documentation reference code on tuning a linearGAM model #276

Closed LucLapenta closed 4 years ago

LucLapenta commented 4 years ago

Updated documentation reference code on tuning a linearGAM model to be accurate compared to what the comments describe.

In the original reference code the numerical outputs at each step did not match the expected results based on the comments: lams = np.random.rand(100, 3) # random points on [0, 1], with shape (100, 3) lams = lams * 8 - 3 # shift values to -3, 3 lams = np.exp(lams) # transforms values to 1e-3, 1e3

The second step lams = lams * 8 - 3 # shift values to -3, 3 results in shifting the random values from -3,5 rather than -3,3.

The third step lams = np.exp(lams) # transforms values to 1e-3, 1e3 is computing e^lams when is seems like it is supposed to be computing 10^lams.

After running the original reference code, the min and max values are the resulting matrix are 0.04992659817158999 and 148.3540116029961 respectively.

The reference code in the quick_start.ipynb notebook was modified to: lams = np.random.rand(100, 3) # random points on [0, 1], with shape (100, 3) lams = lams * 6 - 3 # shift values to -3, 3 lams = 10 ** lams # transforms values to 1e-3, 1e3

Which results in more correct minimum and maximum values in the range of [1e-3, 1e3].

codecov[bot] commented 4 years ago

Codecov Report

Merging #276 into master will increase coverage by 0.09%. The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #276      +/-   ##
==========================================
+ Coverage   95.12%   95.21%   +0.09%     
==========================================
  Files          22       22              
  Lines        3178     3178              
==========================================
+ Hits         3023     3026       +3     
+ Misses        155      152       -3     
Impacted Files Coverage Δ
pygam/pygam.py 94.79% <0.00%> (+0.12%) :arrow_up:
pygam/utils.py 87.73% <0.00%> (+0.30%) :arrow_up:
pygam/tests/test_GAM_methods.py 100.00% <0.00%> (+0.36%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 2323eb7...5e2f21f. Read the comment docs.

dswah commented 4 years ago

@LucLapenta Thanks for the PR! looks good :)