pythonDEA is a focused Python library for slack-based DEA, environmental
frontiers, and panel productivity analysis. It uses NumPy and SciPy for the
numerical core and exposes a consistent fit() interface across its models.
Python already has capable DEA libraries, but lightweight packages tend to focus on classical radial models.
Tools that combine SBM, undesirable outputs, and productivity analysis often target older Python versions or bring desktop interfaces and larger solver stacks.
pythonDEA provides a focused MIT-licensed option for Python 3.10 and newer, with explicit model choices and result objects that retain solver details, slacks, targets, peer information, and reproducibility metadata.
Install the current version from GitHub:
python -m pip install "git+https://github.com/randomcat4/pythonDEA.git"The core package depends only on NumPy and SciPy. Install the optional
tables extra if you want pandas conversion helpers:
git clone https://github.com/randomcat4/pythonDEA.git
cd pythonDEA
python -m pip install -e ".[tables]"The bundled emissions dataset contains three decision-making units with the same input and desirable output but different undesirable output levels.
from pythondea import audit_result, fit
from pythondea.datasets import load_emissions_cross_section
data = load_emissions_cross_section()
result = fit("sbm", data, orientation="bad_output_adjusted")
for row in result.table("efficiency").rows:
print(f"{row['dmu']}: {row['score']:.6f}")
print("audit passed:", audit_result(result).passed)Expected output:
clean: 1.000000
balanced: 0.923077
dirty: 0.785714
audit passed: True
audit_result() checks that the result contains its primary table, solver
metadata, package version, and a deterministic result hash. It is a metadata
check, separate from validating the assumptions of a chosen DEA model.
Rows represent decision-making units and columns represent variables:
from pythondea import DEAData, fit
data = DEAData(
inputs=[[1.0], [1.0], [1.0]],
good_outputs=[[1.0], [1.0], [1.0]],
bad_outputs=[[1.0], [1.2], [2.2]],
dmu_names=["clean", "balanced", "dirty"],
input_names=["capital"],
good_output_names=["output"],
bad_output_names=["emissions"],
)
result = fit("directional_distance", data, direction="bad_output")Use PanelDEAData.from_3d() for balanced panel data. The first dimension is
period, the second is entity, and the third is variable. DataFrame adapters
are available as dea_from_dataframe() and panel_from_dataframe() when the
tables extra is installed.
| Model name | Purpose | Data type |
|---|---|---|
sbm |
Slack-based efficiency with CRS or VRS, orientation choices, and undesirable outputs | DEAData |
sbm_super_efficiency |
Exclude-self SBM for ranking efficient units and checking frontier sensitivity | DEAData |
sbm_malmquist |
Adjacent-period SBM-Malmquist productivity decomposition | PanelDEAData |
directional_distance |
Directional distance analysis for environmental frontiers | DEAData |
malmquist_luenberger |
Adjacent-period green productivity analysis based on directional distances | PanelDEAData |
Run list_models() to inspect the registered model names. model_catalog()
also returns each model's family, summary, keywords, and citation hint.
Every model returns a ModelResult with the same basic interface:
primary = result.table()
rows = primary.rows
frame = primary.to_pandas() # requires the tables extra
json_text = result.to_json()
run_hash = result.reproducibility_hash()
solver = result.metadata["solver_backend"]SBM results include efficiency, slack, and target tables. Directional distance results include distance and target tables. Panel models return one row per entity and adjacent-period transition.
pythonDEA concentrates on non-radial and directional methods used in environmental efficiency and panel productivity research. Current development focuses on numerical validation and richer frontier diagnostics. The model registry also lets external estimators use the same data and result interfaces.
| Path | Role |
|---|---|
v1/ |
Original standalone SBM-Malmquist tool and its archived documentation |
v2/ |
Tested numerical core for data, frontiers, SBM, DDF, and panel calculations |
v3/pythondea/ |
Current importable package; the directory name is retained from the package-layer rewrite |
examples/ |
Small scripts for SBM-Malmquist and green productivity reproduction |
tests/ |
Numerical, API, adapter, audit, and example tests |
The package version is independent of the historical directory names. The
current release metadata reports version 4.0.0.
git clone https://github.com/randomcat4/pythonDEA.git
cd pythonDEA
python -m pip install -e ".[dev,tables]"
python -m pytestThe repository also includes two runnable examples:
python examples/v3_sbm_malmquist_reproduction.py
python examples/v4_green_productivity_reproduction.pyThe staged implementation plan is in TODO.md.
pythonDEA is released under the MIT License.