Maths

patsy – Python package for statistical data transformations

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-learnMachine learning library for Python
NumPyCore package for scientific computing with Python
SciPyEcosystem for mathematics, science, and engineering.
statsmodelsStatistical modeling and econometrics
JAXPython library for high-performance numerical computing
SageMathComputer algebra system
SymPyLibrary for symbolic mathematics
PyMCBayesian statistical modeling and probabilistic programming
PyomoObject-oriented algebraic modeling language
patsyPackage for describing statistical models and to build design matrices
mpmathLibrary for arbitrary-precision floating-point arithmetic
SfePyFinite element software package

Read our verdict in the software roundup.


Best Free and Open Source Software 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.
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted