Comments (7)
Hi @petrhrobar ,
Formulaic already supports poly
(orthogonal polynomial) and bs
(basis splines) bases. Which additional spline bases do you need?
from formulaic.
Hey There,
COOL!. I was not aware of this. Is there any form of documentation covering the poly
and bs
features?
from formulaic.
Online documentation is a weak point... but we'll get there. Currently the only documentation is the grammar documentation, which indicates that support exists: https://matthewwardrop.github.io/formulaic/concepts/grammar/#transforms.
The API for these transforms is the same as patsy/R, and the inline documentation is thorough (e.g. https://github.com/matthewwardrop/formulaic/blob/main/formulaic/transforms/basis_spline.py#L37). The website documentation needs to be updated, but I already know this so I'll close this out for now :).
from formulaic.
Thanks for that.
Just a follow-up - how to change degrees of freedom in string formula:
import seaborn as sns
from formulaic import Formula, formula
df = sns.load_dataset("tips")
Formula("total_bill ~ bs(size, df = 10)").get_model_matrix(df)
If I call the function itself, it works. however, having it changeable in the string is what I would like:
from formulaic.transforms import basis_spline, poly
pd.DataFrame(basis_spline(df['size'], degree = 10)).values
from formulaic.
Hi again!
The bs
function in the formula is literally basis_spline
... so you would pass the arguments through directly. For example:
from formulaic.transforms import basis_spline, poly
pd.DataFrame(basis_spline(df['size'], degree = 10)).values
would be achieved using:
from formulaic import Formula
Formula("bs(size, degree = 10)").get_model_matrix(df)
Does this not work for you?
from formulaic.
Ah... I see. There's a bug in the stateful evaluation that attempts to treat the 10
constant as a column to be evaluated. I'll resolve that ahead of the next release!
from formulaic.
The issue above was due to a bug / issue in astor <0.8. I bumped the dependency, and things should work now on the master branch; soon to be 0.3.4.
from formulaic.
Related Issues (20)
- __repr__() got an unexpected keyword argument 'to_str' HOT 1
- Query the number of formula terms HOT 5
- Sparse matrix creation is slow HOT 2
- Explicitly passed terms should be sorted like parsed terms. HOT 4
- Make a `Q` operator that behaves like patsy's Q. HOT 3
- Feature Request: circular transform HOT 3
- bug: incorrect metadata license file HOT 2
- Allow interaction with yourself HOT 1
- Test failures: `AssertionError: approx() is not supported in a boolean context.` HOT 4
- drop both columns in dependent variable and design matrix when missings occur HOT 5
- DOC: Explicitly mention support for multiple variables on the left hand side HOT 3
- Terms not being evaluated in get_model_matrix() HOT 2
- 17 tests fail: ModuleNotFoundError: No module named 'interface_meta' HOT 2
- How can the encoding choices for one dataset be reused for another? HOT 3
- Intercept term breaks when RHS formula begins with a parentheses HOT 2
- How do I set the reference level for a categorical term? HOT 4
- Support for sympy >= 1.10 HOT 3
- ENH: Preserve variable order as they appear in formulas HOT 5
- 2 tests fail HOT 1
- Interaction between two categorical covariates sometimes switches order, causing error HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from formulaic.