patsy is an open source Python library for describing statistical models (especially linear models, or models that have a linear component) and building design matrices.
This tool is useful for anyone doing machine learning. It transforms data into statistically relevant ways in order to improve the machine learning model, particularly linear models.
It’s closely inspired by and compatible with the formula mini-language used in R and S. It offers a high-level language for describing which factors you want your underlying model to take into account.
The software aims to become the standard high-level interface to describing statistical models in Python, regardless of what particular model or library is being used underneath.
patsy brings the convenience of R “formulas” to Python. patsy needs Python (2.7, or 3.4+), six, and NumPy.
Key Features
- Very high degree of compatibility with R.
- Allows data transformations to be specified using arbitrary Python code: instead of x, we could have written log(x), (x > 0), or even log(x) if x > 1e-5 else log(1e-5).
- Provides a range of convenient options for coding categorical variables, including automatic detection and removal of redundancies.
- Knows how to apply ‘the same’ transformation used on original data to new data, even for tricky transformations like centering or standardization (critical if you want to use your model to make predictions).
- Has an incremental mode to handle data sets which are too large to fit into memory at one time.
- Provides a language for symbolic, human-readable specification of linear constraint matrices.
- Has a thorough test suite (>97% statement coverage) and solid underlying theory, allowing it to correctly handle corner cases that even R gets wrong.
- Supports Pandas’s new (version 0.15 or later) categorical objects.
- Features a simple API for integration into statistical packages.
Website: pypi.org/project/patsy
Support: Documentation, GitHub Code Repository, Mailing List
Developer: Nathaniel J. Smith – Patsy Developers
License: 2-clause BSD 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.
Explore our comprehensive directory of recommended free and open source software. Our carefully curated collection spans every major software category.This directory is part of our ongoing series of informative articles for Linux enthusiasts. It features hundreds of detailed reviews, along with open source alternatives to proprietary solutions from major corporations such as Google, Microsoft, Apple, Adobe, IBM, Cisco, Oracle, and Autodesk. You’ll also find interesting projects to try, hardware coverage, free programming books and tutorials, and much more. Discovered a useful open source Linux program that we haven’t covered yet? Let us know by completing this form. |

