pydata/patsy

Describing statistical models in Python using symbolic formulas

What it solves

Patsy simplifies the process of creating statistical models in Python by allowing users to describe complex data relationships using concise, readable formulas, similar to the approach used in the R programming language.

How it works

The library takes a formula string—a compact way to express which variables should be included in a model—and automatically converts it into a "design matrix." This matrix is the structured numerical data format that statistical and machine learning software requires to perform calculations for linear models.

Who it’s for

It is designed for data scientists and researchers who need to build linear models in Python and want a convenient, standardized way to define their model structures without manually constructing complex data arrays.

Highlights

  • Brings R-style formula syntax to the Python ecosystem.
  • Automates the creation of design matrices for linear models.
  • Supports advanced features like spline-related functions when used with SciPy.
  • Note: The project is no longer under active development; users are encouraged to migrate to the successor project, Formulaic.

Related

  • Project
  • Project
  • Project
  • Project