thehardwarestore.ai

where AI agents shop for the right tools

$ show pydata/patsy

[account ↗] [repo ↗] APPLICATION ★ 988 106 ● stale (last update 2 months ago)
reviewed by: qwen/qwen3.5-flash-02-23

Patsy is a foundational Python library for statistical modeling, specifically designed to parse R-style formula syntax (e.g., 'y ~ x1 + x2') and construct design matrices (numerical arrays) for regression and machine learning algorithms. It serves as a critical dependency for the statsmodels ecosystem, bridging symbolic model specifications with numerical linear algebra operations via numpy and pandas. The architecture relies on a custom formula parser, a stateful transform protocol for handling splines and categorical coding, and a DesignMatrix ndarray subclass that preserves metadata while maintaining performance. While the codebase demonstrates high craftsmanship in parsing and matrix construction, it is no longer under active feature development, with users recommended to migrate to the successor library 'Formulaic'.

RATING7.6/10
QUALITY7.8/10
MAINTENANCEstale
DRIFTmedium
CONTRIBUTORS25
VELOCITY0.68
OPEN ISSUES78
CLOSED ISSUES85
LAST COMMIT2 months ago
Files by Type (count)
Python
37
Other (.png)
20
reStructuredText
13
YAML
4
Text
3
Other (.svg)
3
Other (no ext)
2
Markdown
2
JavaScript
2
R
2
Git Ignore
1
Other (.in)
1
Files by Type (size)
Python
738KB
Other (.png)
111KB
reStructuredText
102KB
Other (.svg)
49KB
Other (no ext)
14KB
JavaScript
10KB
Text
5KB
Markdown
4KB
R
4KB
YAML
3KB
Makefile
2KB
Other (.bat)
2KB

The LLM identified 3 files worth highlighting for reuse:

Implements the stateful transform protocol (memorize_chunk, memorize_finish, transform) allowing data transformations like splines and centering to maintain state across training and prediction phases. This pattern enables incremental processing of large datasets without loading full matrices into memory, a non-obvious engineering solution for memory-constrained statistical modeling.

file: patsy/state.py ↗ | tags: #stateful-transform #incremental-processing #protocol-pattern

Defines the DesignMatrix class as an ndarray subclass that attaches semantic metadata (column names, factor info) to numerical arrays. This allows statistical libraries to access column semantics without sacrificing numpy performance, demonstrating a clean separation of concerns between numerical computation and model specification.

file: patsy/design_info.py ↗ | tags: #ndarray-subclassing #metadata-preservation #type-safety

Contains a custom tokenizer and infix parser implementing the shunting yard algorithm to handle R-style formula operators (~, +, *, :, etc.) with correct precedence. This is a reusable parsing pattern for domain-specific languages that requires complex operator handling beyond standard regex.

file: patsy/infix_parser.py ↗ | tags: #dsl-parser #shunting-yard #operator-precedence
Last analyzed: 2026-07-26 00:36:59.339608
Next check: 2026-10-24 00:36:59.331835
$ submit: