pyGAM icon indicating copy to clipboard operation
pyGAM copied to clipboard

patsy like formula creation

Open arose13 opened this issue 5 years ago • 5 comments

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

  • I haven't added in col_a * col_b yet.
  • I deliberately have not allowed adding the other kwargs because at that point it would probably make more sense to use the old solution. If anything I'll modify that solution to get the index from the column name (since that is the most annoying and error-prone).

arose13 avatar Jul 10 '19 01:07 arose13

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.

codecov[bot] avatar Jul 10 '19 15:07 codecov[bot]

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

arose13 avatar Jul 10 '19 18:07 arose13

@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)

dswah avatar Jul 15 '19 21:07 dswah

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

arose13 avatar Jul 15 '19 21:07 arose13

I think this is a very nice feature!

silviobe avatar Sep 11 '20 09:09 silviobe