Metadata-Version: 2.4
Name: orange3-dea
Version: 1.1.0
Summary: Data Envelopment Analysis add-on for Orange3
Author-email: Lan Umek <lan.umek@fu.uni-lj.si>
License: MIT
Project-URL: Homepage, https://github.com/lan-umek/orange3-dea
Project-URL: Documentation, https://github.com/lan-umek/orange3-dea/tree/main/docs
Project-URL: Repository, https://github.com/lan-umek/orange3-dea
Project-URL: Issues, https://github.com/lan-umek/orange3-dea/issues
Keywords: orange3 add-on,DEA,efficiency,data envelopment analysis
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Scientific/Engineering :: Information Analysis
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy
Requires-Dist: scipy>=1.6
Requires-Dist: matplotlib
Provides-Extra: gui
Requires-Dist: Orange3>=3.34; extra == "gui"
Requires-Dist: AnyQt; extra == "gui"
Provides-Extra: test
Requires-Dist: pytest; extra == "test"
Dynamic: license-file

# Orange3-DEA — Data Envelopment Analysis Add-on

An Orange3 add-on for **Data Envelopment Analysis (DEA)**, inspired by the
[deaR-Shiny](https://doi.org/10.3390/su13126774) web application (Benítez,
Coll-Serrano & Bolós, 2021). This is a full reimplementation of the original
prototype with corrected solvers, background execution, and new widgets.

## Widgets

| Widget | Description |
|---|---|
| **DEA Datasets** | Built-in datasets from published papers; panel datasets are sent as a *DEA Panel*, fuzzy datasets on a dedicated channel. Loads automatically on selection. |
| **DEA Setup** | Select the DMU identifier, inputs and outputs. Settings persist by variable name; the *Filtered Data* output contains exactly the rows used in the analysis. |
| **DEA Model** | Choose and run a model. Runs in a background thread (the GUI stays responsive), re-runs automatically on new input, and can attach scale efficiency (CRS/VRS/SE + RTS class). |
| **DEA Results** | Sortable tabs: efficiency (with rank and peer counts), slacks, targets (with % change), lambdas, reference sets, cross-efficiency matrix, bootstrap intervals. Sends four Orange Tables. |
| **DEA Plot** | Efficiency bars, summary, histogram, peer frequency, and a production-frontier plot (1 input × 1 output) with a zoom/save toolbar. |
| **DEA Malmquist** *(new)* | Malmquist productivity index over a DEA Panel or two DEA Problems: MI = EC × TC, with optional pure/scale decomposition (PEC × SEC). |
| **DEA Window** *(new)* | Window analysis (Charnes et al. 1985): efficiency inside moving windows of consecutive periods, with per-DMU stability summary (mean, SD, min, max). |
| **DEA Context** *(new)* | Context-dependent DEA (Seiford & Zhu 2003): efficiency tiers by frontier peeling, attractiveness and progress scores at a chosen tier distance. |
| **DEA Tests** *(new)* | Banker (1993) RTS tests (exponential and half-normal), plus group-difference tests on efficiency scores: Mann-Whitney, Kolmogorov-Smirnov, Li (1996) with bootstrap p-value, Kruskal-Wallis. |
| **DEA Two-Stage** *(new)* | Simar-Wilson (2007) double bootstrap: truncated regression of DEA scores on environmental covariates with bias correction and valid confidence intervals. |
| **DEA Network** *(new)* | Serial two-stage network DEA: overall = stage 1 × stage 2 (Kao-Hwang 2008) or weighted mean (Chen et al. 2009, CRS/VRS); assign inputs, intermediates and outputs directly from a data table. |
| **DEA Economic** *(new)* | Cost, revenue and profit efficiency with prices; Farrell decomposition (economic = technical × allocative), Nerlovian profit inefficiency. |
| **DEA Conditional** *(new)* | Conditional order-m (Daraio-Simar 2005): kernel-weighted peers in environmental variables; Q = conditional/unconditional diagnoses the environment's effect nonparametrically. |
| **DEA Metafrontier** *(new)* | Group frontiers vs. pooled metafrontier with technology gap ratios (O'Donnell et al. 2008). |
| **DEA Multiverse** *(new, methodological contribution)* | Specification-curve analysis for DEA: runs ~23 defensible specifications (model × orientation × RTS × convexity × frontier type), reports rank distributions with a boxplot, consensus ranking, per-DMU robustness and efficient share, Kendall's W agreement, and an η² decomposition of which methodological choice drives the results. See METHOD_MULTIVERSE.md. |
| **DEA PCA** *(new)* | PCA-DEA (Adler-Golany 2001/2002): principal components per block (standardized, sign-fixed, translated to positive), DEA on components; restores discrimination with many variables. Shows loadings and rank agreement with the full model. |
| **DEA Common Weights** *(new)* | CCA-based common weights (Sinuany-Stern et al. 1994; Friedman & Sinuany-Stern 1997): one weight vector for all DMUs → complete ranking; canonical correlation and Spearman agreement with CCR reported. |
| **DEA Cluster** *(new)* | Discover technology groups by clustering DMUs — on input-output profiles, on the λ (peer) structure ("benchmark communities"), or on multiverse rank profiles; k-means/Ward, automatic k by silhouette; feeds groups straight to DEA Metafrontier. |
| **DEA Map** *(new)* | 2-D MDS map of DMUs (Co-Plot spirit, Adler & Raveh 2008) colored by efficiency with efficient units starred; distances from profiles, cross-efficiency appraisal profiles, or multiverse rank profiles; Kruskal stress reported. |
| **DEA Fuzzy** *(new)* | Kao-Liu fuzzy DEA GUI: efficiency intervals per α-cut (table + interval plot); consumes the Fuzzy DEA Problem output of DEA Datasets. |
| **DEA SFA** *(new)* | Stochastic frontier (Cobb-Douglas, half-normal MLE) as a parametric benchmark: elasticities, γ diagnostics, DEA-vs-SFA scatter with Spearman ρ. |
| **DEA Export** *(new)* | Any result table → publication-ready booktabs LaTeX or CSV (preview, clipboard, save). |

Example workflows are in `examples/` (basic analysis, panel productivity, undesirable outputs, research/multiverse); see **USER_GUIDE.md** for recommended analysis paths and **CHANGELOG.md** for version history.

## Implemented models

| Category | Model | Notes |
|---|---|---|
| Radial | CCR / BCC | **Two-phase** (slacks maximized at the optimal radial factor), so weakly efficient DMUs are identified correctly; CRS/VRS/NIRS/NDRS |
| Non-radial | Additive | Weights: ones / MIP / RAM; score = total slack (0 = efficient), RAM score in [0, 1] |
| Non-radial | SBM (Tone 2001) | Non-oriented, input- and output-oriented |
| Non-radial | Russell | Per-input/per-output factors |
| Directional | DDF (Chambers et al. 1996) | β = 0 means efficient |
| Ranking | Radial super-efficiency | Infeasible LPs under VRS reported explicitly |
| Ranking | Super-SBM (Tone 2002) | Only SBM-efficient DMUs re-scored |
| Ranking | Cross-efficiency | Arbitrary / **benevolent** / **aggressive** secondary goals (Doyle & Green 1994) |
| Non-convex | FDH | Enumeration |
| Inference | Bootstrap (Simar & Wilson 1998) | **Smoothed** bootstrap with reflection, bias correction, CIs, reproducible seed |
| Panel | Malmquist (Färe et al. 1994) | EC/TC + optional PEC/SEC decomposition; consistent for both orientations |
| Fuzzy | Kao & Liu alpha-cuts | Correct per-DMU best/worst scenarios (API only) |
| Extras | Scale efficiency | SE = TE(CRS)/TE(VRS) with IRS/DRS/CRS classification |
| Environmental | Seiford-Zhu (2002) | Bad outputs translated and treated as goods (VRS); mark undesirable outputs in DEA Setup |
| Environmental | Environmental DDF (Chung et al. 1997) | Weak disposability: expands good outputs, contracts bad outputs |
| Weights | Multiplier form + assurance regions | Ratio bounds on input/output weights, text syntax `a / b in [lo, hi]`; lambdas recovered from LP duals |
| Robust | Order-m (Cazals-Florens-Simar 2002) | Partial frontier, insensitive to outliers; Monte Carlo with seed |
| Panel | Window analysis | Moving-window pooled frontiers |
| Benchmarking | Context-dependent DEA | Tier stratification, attractiveness/progress |
| Inference | Banker (1993) RTS tests | Exponential F(2n,2n) and half-normal F(n,n) variants |
| Inference | Li (1996) test | Kernel density equality with bootstrap p-value; plus MW/KS/KW |
| Inference | Simar-Wilson (2007) Algorithm 2 | Double-bootstrap truncated regression (L1 bias correction, L2 coefficient CIs) |
| Network | Kao-Hwang (2008), Chen et al. (2009) | Two-stage serial network with exact multiplicative/additive decomposition |
| Economic | Cost / revenue / profit efficiency | Farrell decomposition with per-DMU or common prices |
| Panel | Global Malmquist (Pastor-Lovell 2005) | Circular index over a pooled global frontier (TC column = best-practice gap change) |
| Panel | Malmquist-Luenberger (Chung et al. 1997) | Green productivity with weak disposability of bad outputs |
| Panel | Bootstrap CIs for Malmquist | Pairs bootstrap over the panel (approximate; seeded) |
| Robust | Order-α (Daouia-Simar 2005) | Quantile frontier; α = 1 reproduces FDH; in DEA Model |
| Robust | Conditional order-m (Daraio-Simar 2005) | Kernel-weighted peers in Z; Q diagnostics |
| Screening | Wilson (1993) outliers | Leave-one-out super-efficiency flags; in DEA Tests |
| Groups | Metafrontier + TGR | TE_meta = TE_group × TGR |
| Meta | **DEA Multiverse** | Specification-space analysis: consensus ranks, robustness, Kendall's W, η² factor influence (see METHOD_MULTIVERSE.md) |
| Multivariate | PCA-DEA (Adler-Golany) | Block-wise PCA with translation; discrimination diagnostics |
| Multivariate | **NMF-DEA** | Non-negative factorization per block: no translation needed, archetypal profiles; same widget as PCA-DEA |
| Multivariate | CCA common weights | First canonical pair as common weights; complete ranking |
| Multivariate | Cluster-DEA | Profiles / peer-structure / multiverse-rank clustering with silhouette and auto-k; pipeline to metafrontier |
| Multivariate | MDS efficiency map | Classical MDS with stress-1; multiverse-rank distances are a novel option |
| Inference | Tobit second stage | Censored MLE with SEs and p-values, offered alongside Simar-Wilson in DEA Two-Stage (with the methodological caveat) |

## What was fixed relative to the prototype

- Radial model now runs a **second phase**, so "efficient" means strongly
  (Pareto) efficient; targets are computed from the phase-2 lambdas.
- Additive model no longer reports a meaningless 0/1 score; NIRS/NDRS
  constraints are no longer silently dropped (additive, SBM, super-SBM).
- DDF had an inverted sign on the input direction; fixed.
- "Additive-min" (which always returned 1.0 by construction) was removed.
- Cross-efficiency now solves the Doyle–Green secondary-goal LP instead of
  relying on arbitrary epsilon bounds.
- Malmquist handles the output orientation via proper distance functions
  (1/φ), so MI > 1 always means productivity growth.
- Bootstrap is a genuine Simar–Wilson smoothed bootstrap (was: naive
  resampling), with a random seed for reproducibility.
- Kao–Liu fuzzy intervals evaluate each DMU at its own best/worst scenario
  (was: one common scenario for all DMUs — incorrect).
- The DEA Setup widget's *Filtered Data* output was not filtered; fixed,
  along with settings restore bugs and index-based DMU selection.
- Long runs no longer freeze the GUI (background threads in DEA Model and
  DEA Malmquist).

## Installation

```bash
pip install -e .          # from this directory
```

Then launch Orange Canvas — the **DEA** category appears in the toolbox.

## Typical workflow

```
File / DEA Datasets → DEA Setup → DEA Model → DEA Results → DEA Plot
                    ↘ (DEA Panel) → DEA Malmquist
```

## Programmatic use

```python
from orangecontrib.dea.core import DEAProblem, run_dea

problem = DEAProblem(dmu_names, input_names, output_names, X, Y)
res = run_dea(problem, model="Basic Radial (CCR/BCC)",
              orientation="input", rts="VRS")
print(res.efficiency, res.efficient, res.reference_set(0))
```

## Tests

```bash
pytest orangecontrib/dea/tests
```

65 tests cover closed-form CCR scores, model orderings (CCR ≤ NIRS ≤ BCC,
SBM ≤ radial, Russell ≤ radial, FDH ≥ VRS, order-m ≥ FDH), weak-efficiency
detection, super-efficiency, cross-efficiency consistency, Malmquist
identities, bootstrap reproducibility, fuzzy interval nesting,
multiplier/envelopment equivalence, weight-restriction monotonicity,
weak-disposability targets, window/context properties, Li-test power and
size, recovery of a known covariate effect in the Simar-Wilson two-stage
model, the Kao-Hwang product identity, network ≤ black-box efficiency,
Farrell decompositions, global-Malmquist circularity and identity,
Malmquist-Luenberger identity, order-α = FDH at α = 1 with monotonicity,
conditional order-m reproducibility, outlier flagging, and TGR ≤ 1 with
TE_meta = TE_group × TGR.

## References

- Charnes, Cooper & Rhodes (1978). *EJOR* 2(6), 429–444.
- Banker, Charnes & Cooper (1984). *Management Science* 30(9), 1078–1092.
- Tone (2001, 2002). *EJOR* 130(3), 498–509; 143(1), 32–41.
- Doyle & Green (1994). *JORS* 45(5), 567–578.
- Färe, Grosskopf, Norris & Zhang (1994). *AER* 84(1), 66–83.
- Simar & Wilson (1998). *Management Science* 44(1), 49–61.
- Simar & Wilson (2007). *Journal of Econometrics* 136(1), 31–64.
- Kao & Liu (2000). *Fuzzy Sets and Systems* 113(3), 427–437.
- Seiford & Zhu (2002). *EJOR* 142(1), 16–20. (undesirable outputs)
- Seiford & Zhu (2003). *EJOR* 151(2), 411–420. (context-dependent)
- Chung, Färe & Grosskopf (1997). *J. Environ. Manage.* 51(3), 229–240.
- Cazals, Florens & Simar (2002). *J. Econometrics* 106(1), 1–25.
- Banker (1993). *Management Science* 39(10), 1265–1273.
- Li (1996). *Econometric Reviews* 15(3), 261–274.
- Charnes, Clark, Cooper & Golany (1985). *Annals of OR* 2, 95–112. (window)
- Benítez, Coll-Serrano & Bolós (2021). *Sustainability* 13(12), 6774.

## License

MIT
