Análise Envoltória de Dados (DEA) simples, robusta e extensível em Python.
Project description
opendea
Data Envelopment Analysis (DEA) in Python — simple, robust, and extensible, built on SciPy.
Includes CCR (CRS) and BCC (VRS) models, super-efficiency, additive model,
as well as modules for NDEA (two-stage networks) and Dynamic DEA with carry-overs.
⚠️ Note: The SBM (Slack-Based Measure, Tone 2001) is included in the code but inactive in version 0.1.0.
It will be available in a future release (0.2.0).
📦 Installation
User (pip)
pip install opendea # core only
pip install opendea[viz] # core + plotting (matplotlib, seaborn)
pip install opendea[full] # everything: plotting + notebooks + dev tools
Development
git clone https://github.com/yourusername/opendea.git
cd opendea
python -m venv .venv && source .venv/bin/activate
pip install -e ".[dev,viz]"
⚡ Quickstart
import pandas as pd
from opendea import dea_ccr_input, dea_bcc_output
from opendea.plotting import plot_efficiency
df = pd.DataFrame({
"x1": [4, 2, 3, 5],
"x2": [2, 1, 1, 3],
"y1": [1, 1, 1, 2],
}, index=["A","B","C","D"])
# CCR (CRS) input-oriented
res_ccr_in = dea_ccr_input(df, inputs=["x1","x2"], outputs=["y1"])
print(res_ccr_in[["efficiency"]])
# BCC (VRS) output-oriented
res_bcc_out = dea_bcc_output(df, inputs=["x1","x2"], outputs=["y1"])
print(res_bcc_out[["phi"]])
# Plot efficiencies
plot_efficiency(res_ccr_in, title="CCR Efficiency")
🧰 Main API
Classical models
dea_ccr_input(df, inputs, outputs)dea_bcc_input(df, inputs, outputs)dea_ccr_output(df, inputs, outputs)dea_bcc_output(df, inputs, outputs)
Extensions
super_eff_ccr_input(df, inputs, outputs)super_eff_ccr_output(df, inputs, outputs)dea_additive_ccr(df, inputs, outputs)dea_additive_bcc(df, inputs, outputs)🚫 inactive in v0.1.0dea_sbm_input(df, inputs, outputs, vrs=True)
Advanced
ndea_two_stage_input(df, inputs_stage1, link_m, outputs_stage2, vrs=True)dynamic_dea_input(panels, inputs, outputs, carryovers, vrs=True)
Utilities
projections(df, inputs, outputs, result, orientation="input"|"output")peers_from_lambdas(result)
🧠 Conventions (summary)
- Input-oriented: minimize θ
Projections:x* = θ·x0 − s−;y* = y0 + s+ - Output-oriented: maximize φ
Projections:x* = x0 − s−;y* = φ·y0 + s+ - SBM (ρ): 0–1, average proportional reduction in inputs.
- Results return a
DataFrame(orDEAResultin typed API) with columns:efficiency(θ) orphi(φ) orrho(SBM)lambda_*(intensities)s_minus_*,s_plus_*(slacks)
🔬 Advanced examples
NDEA (two-stage in series)
from opendea import ndea_two_stage_input
df_net = pd.DataFrame({
"x1":[4,2,3,5], "x2":[2,1,1,3],
"m1":[3,2,2,4], # link Stage1->Stage2
"y1":[1,1,1,2],
}, index=list("ABCD"))
res_net = ndea_two_stage_input(df_net, ["x1","x2"], ["m1"], ["y1"], vrs=True)
print(res_net[["efficiency"]])
Dynamic DEA with carry-overs
from opendea import dynamic_dea_input
panels = {
1: pd.DataFrame({"x1":[5,3,4], "y1":[1,1,2], "k1":[2,1,1]}, index=["A","B","C"]),
2: pd.DataFrame({"x1":[4,3,3], "y1":[2,1,2], "k1":[2,1,1]}, index=["A","B","C"]),
}
dyn = dynamic_dea_input(panels, inputs=["x1"], outputs=["y1"], carryovers=["k1"], vrs=True)
for t, df_t in dyn.items():
print(t, df_t[["efficiency"]])
🗺️ Roadmap
- Cross-efficiency (benevolent/aggressive)
- Window analysis (sliding windows)
- Malmquist TFP
- Multiplier (dual) models and Assurance Region I/II
- Extended NDEA / Dynamic (network-SBM, dynamic-SBM)
- Directional distance functions (DDF), robust/stochastic DEA, sensitivity analysis
🧪 Tests
pytest -q
🤝 Contributing
- PRs are welcome!
- Run
ruff+blackbefore submitting. - Always add tests.
📄 License
MIT — see LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file opendea_allys-0.1.1.tar.gz.
File metadata
- Download URL: opendea_allys-0.1.1.tar.gz
- Upload date:
- Size: 23.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e80abab0f6b521771b44ffd17b8f25945708811f89a879e2d30b428b5ce3b1e6
|
|
| MD5 |
07727c5f8c13d84a2a4735252129cd0e
|
|
| BLAKE2b-256 |
e24e4bca3c93f6d1393d422e88dab4d7139ad0ad4beb8689e64f3d66c63d0031
|
File details
Details for the file opendea_allys-0.1.1-py3-none-any.whl.
File metadata
- Download URL: opendea_allys-0.1.1-py3-none-any.whl
- Upload date:
- Size: 23.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eba9f6e6c285cdcf28c3aec761812670f0161f800e58fe58c2fe3c1aedfd8bfa
|
|
| MD5 |
1b26e9c1e28e29bfd6c84c230f5ca36f
|
|
| BLAKE2b-256 |
3053593a1dc8f8bb7b27fdff92147bdda41689c772dc20aeb38e0d7af39a3a88
|