dswah / pyGAM

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

patsy like formula creation #249

Open arose13 opened 5 years ago

arose13 commented 5 years ago

I've been using this for my own work and I feel the average joe and jane would like that they can use this package like more like the R package. This is because of the term list method currently used only allows Numpy column indices.

Now you can you import from_formula() and use it like the following.

LinearGAM(from_formula('y ~ *', df))
LinearGAM(from_formula('y ~ l(mode) + price + day_of_year + c(location)', df)) 

c is just like R and statsmodels and allows you to declare a column as a factor l, s allows you to unambiguously declare terms as linear or spline terms (respectively)

NOTES

codecov[bot] commented 5 years ago

Codecov Report

Merging #249 into master will decrease coverage by 0.26%. The diff coverage is 82.6%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #249      +/-   ##
==========================================
- Coverage   95.18%   94.91%   -0.27%     
==========================================
  Files          22       22              
  Lines        3178     3246      +68     
==========================================
+ Hits         3025     3081      +56     
- Misses        153      165      +12
Impacted Files Coverage Δ
pygam/__init__.py 100% <100%> (ø) :arrow_up:
pygam/tests/test_terms.py 100% <100%> (ø) :arrow_up:
pygam/terms.py 92.62% <78.57%> (-1.59%) :arrow_down:

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 b5c6c55...2513555. Read the comment docs.

arose13 commented 5 years ago

I have no idea why the last commit "Merge branch 'master' into master" dropped my code coverage so substantially.

dswah commented 5 years ago

@arose13 this is awesome! thank you very much!

However, we have recently changed the license to Apache 2.0 to allow proprietary use of the library, which means downstream users would NOT need to release the source-code of their application when they use pyGAM.

The previous GPLv3 license is quite strict, and the hope is that a more passive license will encourage (proprietary) contributors to keep improving this library.

Please let me know if you are ok with this change. Thanks, Danny

Current License: Apache 2.0 (tldr: any use and modifications are allowed, with any license, with or without release source-code. all modifications must be explicitly stated.)

Old license for reference: GPLv3 (tldr: any modifications and downstream applications must be made open-source and released with the same license)

arose13 commented 5 years ago

@dswah Thanks and that's very cool. I am okay with the change in license.

silviobe commented 3 years ago

I think this is a very nice feature!