patsy is a library for describing statistical models using symbolic formulas and converting data into design matrices suitable for statistical analysis.
The formula language is closely inspired by the conventions used in R and S. It allows users to describe explanatory variables, interactions and transformations using concise expressions rather than manually constructing every column required by a statistical model.
A formula can represent both the response variable and the predictors used in a model. patsy interprets the formula, evaluates the relevant data transformations and produces numerical matrices that can be passed to statistical modelling libraries.
The library is particularly useful for regression models, analysis of variance and other statistical methods that require carefully constructed model matrices. It is also used by statistical packages that expose formula-based interfaces to their users.
This is free and open source software.
Key Features
- R-style symbolic formula language for specifying statistical models.
- dmatrix and dmatrices interfaces for creating design matrices from formulas and data.
- Support for response variables, predictor terms, interactions and intercept handling.
- Automatic encoding of categorical variables with appropriate contrast matrices.
- Multiple contrast coding schemes including treatment, sum, Helmert and polynomial contrasts.
- Support for evaluating mathematical transformations within formula expressions.
- Stateful transformations for centering, standardising and applying reusable operations to data.
- Spline basis functions including B-splines and natural or cyclic cubic regression splines.
- Design information objects that preserve the transformations required to process new observations consistently.
- Handling of missing data according to configurable missing-value policies.
- Incremental matrix-building facilities for processing datasets in separate chunks.
- Linear constraint specification using human-readable symbolic expressions.
- Integration with NumPy arrays and pandas data structures.
- Facilities for working with factor names, term slices and the structure of resulting matrices.
- Extensible formula evaluation environment for custom functions and transformations.
Website: pypi.org/project/patsy
Support:
Developer: Nathaniel J. Smith and Patsy Developers
License: BSD 2-Clause ‘Simplified’ License
patsy is written in Python. Learn Python with our recommended free books and free tutorials.
Related Software
| Python Mathematics Tools | |
|---|---|
| scikit-learn | Machine learning library for Python |
| NumPy | Core package for scientific computing with Python |
| SciPy | Ecosystem for mathematics, science, and engineering. |
| statsmodels | Statistical modeling and econometrics |
| JAX | Python library for high-performance numerical computing |
| SageMath | Computer algebra system |
| SymPy | Library for symbolic mathematics |
| PyMC | Bayesian statistical modeling and probabilistic programming |
| Pyomo | Object-oriented algebraic modeling language |
| patsy | Package for describing statistical models and to build design matrices |
| mpmath | Library for arbitrary-precision floating-point arithmetic |
| SfePy | Finite element software package |
Read our verdict in the software roundup.
LinuxLinks helps you discover the best free and open source software for Linux. Explore our extensive collection of recommended applications, including alternatives to popular proprietary software.We also publish software reviews, Linux tutorials, hardware reviews, free programming books and articles covering the wider open source community. Browse our Linux resources to discover more. Know a useful free and open source Linux application we haven't covered? Suggest a program for inclusion. Has your software been featured on LinuxLinks? Display one of our Featured on LinuxLinks badges on your website or GitHub README. |


Please read our Comment Policy before commenting.