econcomplex 1.1.0__tar.gz → 1.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. {econcomplex-1.1.0 → econcomplex-1.2.0}/CHANGELOG.md +92 -0
  2. {econcomplex-1.1.0/econcomplex.egg-info → econcomplex-1.2.0}/PKG-INFO +51 -11
  3. {econcomplex-1.1.0 → econcomplex-1.2.0}/README.md +48 -10
  4. {econcomplex-1.1.0 → econcomplex-1.2.0}/README.pt-BR.md +48 -10
  5. {econcomplex-1.1.0 → econcomplex-1.2.0}/docs/api_reference_en.tex +46 -0
  6. {econcomplex-1.1.0 → econcomplex-1.2.0}/docs/api_reference_pt.tex +46 -0
  7. econcomplex-1.2.0/docs/econcomplex_documentation_en.pdf +0 -0
  8. {econcomplex-1.1.0 → econcomplex-1.2.0}/docs/econcomplex_documentation_en.tex +567 -13
  9. econcomplex-1.2.0/docs/econcomplex_documentation_pt.pdf +0 -0
  10. {econcomplex-1.1.0 → econcomplex-1.2.0}/docs/econcomplex_documentation_pt.tex +582 -13
  11. {econcomplex-1.1.0 → econcomplex-1.2.0}/docs/generate_api_reference.py +29 -1
  12. econcomplex-1.2.0/docs/generate_tutorial.py +710 -0
  13. econcomplex-1.2.0/docs/tutorial_en.tex +476 -0
  14. econcomplex-1.2.0/docs/tutorial_pt.tex +481 -0
  15. {econcomplex-1.1.0 → econcomplex-1.2.0}/econcomplex/__init__.py +48 -3
  16. econcomplex-1.2.0/econcomplex/complexity/diagnostics.py +129 -0
  17. {econcomplex-1.1.0 → econcomplex-1.2.0}/econcomplex/complexity/eci_pci.py +9 -3
  18. econcomplex-1.2.0/econcomplex/complexity/genepy.py +102 -0
  19. {econcomplex-1.1.0 → econcomplex-1.2.0}/econcomplex/core/utils.py +14 -0
  20. {econcomplex-1.1.0 → econcomplex-1.2.0}/econcomplex/outlook/coi_cog.py +19 -23
  21. econcomplex-1.2.0/econcomplex/policy/__init__.py +6 -0
  22. econcomplex-1.2.0/econcomplex/policy/lists.py +364 -0
  23. econcomplex-1.2.0/econcomplex/prediction/__init__.py +7 -0
  24. econcomplex-1.2.0/econcomplex/prediction/entry.py +388 -0
  25. econcomplex-1.2.0/econcomplex/prediction/model.py +424 -0
  26. {econcomplex-1.1.0 → econcomplex-1.2.0}/econcomplex/relatedness/__init__.py +24 -1
  27. {econcomplex-1.1.0 → econcomplex-1.2.0}/econcomplex/relatedness/density.py +151 -0
  28. econcomplex-1.2.0/econcomplex/relatedness/flows.py +109 -0
  29. econcomplex-1.2.0/econcomplex/relatedness/implied.py +123 -0
  30. econcomplex-1.2.0/econcomplex/relatedness/input_output.py +94 -0
  31. econcomplex-1.2.0/econcomplex/relatedness/spatial.py +84 -0
  32. econcomplex-1.2.0/econcomplex/strategy/__init__.py +7 -0
  33. econcomplex-1.2.0/econcomplex/strategy/selection.py +341 -0
  34. {econcomplex-1.1.0 → econcomplex-1.2.0/econcomplex.egg-info}/PKG-INFO +51 -11
  35. {econcomplex-1.1.0 → econcomplex-1.2.0}/econcomplex.egg-info/SOURCES.txt +21 -1
  36. {econcomplex-1.1.0 → econcomplex-1.2.0}/econcomplex.egg-info/requires.txt +3 -0
  37. econcomplex-1.2.0/examples/diversification_strategy.py +169 -0
  38. econcomplex-1.2.0/examples/tutorial.py +145 -0
  39. {econcomplex-1.1.0 → econcomplex-1.2.0}/pyproject.toml +4 -1
  40. {econcomplex-1.1.0 → econcomplex-1.2.0}/tests/test_quality.py +2 -1
  41. econcomplex-1.2.0/tests/test_stage2.py +345 -0
  42. econcomplex-1.2.0/tests/test_stage2b.py +345 -0
  43. econcomplex-1.1.0/docs/econcomplex_documentation_en.pdf +0 -0
  44. econcomplex-1.1.0/docs/econcomplex_documentation_pt.pdf +0 -0
  45. {econcomplex-1.1.0 → econcomplex-1.2.0}/LICENSE +0 -0
  46. {econcomplex-1.1.0 → econcomplex-1.2.0}/MANIFEST.in +0 -0
  47. {econcomplex-1.1.0 → econcomplex-1.2.0}/econcomplex/complexity/__init__.py +0 -0
  48. {econcomplex-1.1.0 → econcomplex-1.2.0}/econcomplex/complexity/eigenvector.py +0 -0
  49. {econcomplex-1.1.0 → econcomplex-1.2.0}/econcomplex/complexity/fitness.py +0 -0
  50. {econcomplex-1.1.0 → econcomplex-1.2.0}/econcomplex/complexity/reflections.py +0 -0
  51. {econcomplex-1.1.0 → econcomplex-1.2.0}/econcomplex/complexity/subnational.py +0 -0
  52. {econcomplex-1.1.0 → econcomplex-1.2.0}/econcomplex/core/__init__.py +0 -0
  53. {econcomplex-1.1.0 → econcomplex-1.2.0}/econcomplex/core/diversity.py +0 -0
  54. {econcomplex-1.1.0 → econcomplex-1.2.0}/econcomplex/core/preprocess.py +0 -0
  55. {econcomplex-1.1.0 → econcomplex-1.2.0}/econcomplex/core/rca.py +0 -0
  56. {econcomplex-1.1.0 → econcomplex-1.2.0}/econcomplex/dynamics/__init__.py +0 -0
  57. {econcomplex-1.1.0 → econcomplex-1.2.0}/econcomplex/dynamics/entry_exit.py +0 -0
  58. {econcomplex-1.1.0 → econcomplex-1.2.0}/econcomplex/dynamics/growth.py +0 -0
  59. {econcomplex-1.1.0 → econcomplex-1.2.0}/econcomplex/inequality/__init__.py +0 -0
  60. {econcomplex-1.1.0 → econcomplex-1.2.0}/econcomplex/inequality/concentration.py +0 -0
  61. {econcomplex-1.1.0 → econcomplex-1.2.0}/econcomplex/inequality/gini.py +0 -0
  62. {econcomplex-1.1.0 → econcomplex-1.2.0}/econcomplex/optimization/__init__.py +0 -0
  63. {econcomplex-1.1.0 → econcomplex-1.2.0}/econcomplex/optimization/diffusion.py +0 -0
  64. {econcomplex-1.1.0 → econcomplex-1.2.0}/econcomplex/optimization/growth_target.py +0 -0
  65. {econcomplex-1.1.0 → econcomplex-1.2.0}/econcomplex/optimization/portfolio.py +0 -0
  66. {econcomplex-1.1.0 → econcomplex-1.2.0}/econcomplex/optimization/steppingstone.py +0 -0
  67. {econcomplex-1.1.0 → econcomplex-1.2.0}/econcomplex/outlook/__init__.py +0 -0
  68. {econcomplex-1.1.0 → econcomplex-1.2.0}/econcomplex/patents/__init__.py +0 -0
  69. {econcomplex-1.1.0 → econcomplex-1.2.0}/econcomplex/patents/recombination.py +0 -0
  70. {econcomplex-1.1.0 → econcomplex-1.2.0}/econcomplex/pipeline.py +0 -0
  71. {econcomplex-1.1.0 → econcomplex-1.2.0}/econcomplex/productivity/__init__.py +0 -0
  72. {econcomplex-1.1.0 → econcomplex-1.2.0}/econcomplex/productivity/prody.py +0 -0
  73. {econcomplex-1.1.0 → econcomplex-1.2.0}/econcomplex/relatedness/cooccurrence.py +0 -0
  74. {econcomplex-1.1.0 → econcomplex-1.2.0}/econcomplex/relatedness/cross_space.py +0 -0
  75. {econcomplex-1.1.0 → econcomplex-1.2.0}/econcomplex/relatedness/proximity.py +0 -0
  76. {econcomplex-1.1.0 → econcomplex-1.2.0}/econcomplex/specialization/__init__.py +0 -0
  77. {econcomplex-1.1.0 → econcomplex-1.2.0}/econcomplex/specialization/location_quotient.py +0 -0
  78. {econcomplex-1.1.0 → econcomplex-1.2.0}/econcomplex/specialization/similarity.py +0 -0
  79. {econcomplex-1.1.0 → econcomplex-1.2.0}/econcomplex.egg-info/dependency_links.txt +0 -0
  80. {econcomplex-1.1.0 → econcomplex-1.2.0}/econcomplex.egg-info/top_level.txt +0 -0
  81. {econcomplex-1.1.0 → econcomplex-1.2.0}/examples/basic_usage.py +0 -0
  82. {econcomplex-1.1.0 → econcomplex-1.2.0}/examples/eci_optimization.py +0 -0
  83. {econcomplex-1.1.0 → econcomplex-1.2.0}/setup.cfg +0 -0
  84. {econcomplex-1.1.0 → econcomplex-1.2.0}/setup.py +0 -0
  85. {econcomplex-1.1.0 → econcomplex-1.2.0}/tests/test_core.py +0 -0
  86. {econcomplex-1.1.0 → econcomplex-1.2.0}/tests/test_diffusion.py +0 -0
  87. {econcomplex-1.1.0 → econcomplex-1.2.0}/tests/test_optimization.py +0 -0
@@ -1,5 +1,97 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.2.0] — unreleased
4
+
5
+ General-purpose tools for the steps that come after the indicators:
6
+ explaining opportunities, ranking them, reading them through lists of
7
+ activities, and testing whether a score predicts entry. 112 public
8
+ functions (22 new). scikit-learn becomes an optional dependency
9
+ (`pip install "econcomplex[ml]"`), needed only by the prediction models.
10
+
11
+ ### Fixed
12
+ - **`complexity_outlook_gain` (`cog`) used the wrong normalization.** The
13
+ gain from entering activity c was divided by the total proximity of c,
14
+ instead of dividing each term by the total proximity of the activity c'
15
+ whose density rises. The two only coincide when every activity has the
16
+ same total proximity. The function now equals the actual change in the
17
+ Complexity Outlook Index when the activity is added (tested), and matches
18
+ the Growth Lab's `py-ecomplexity`. **Values change**: on the sample data
19
+ the correlation with the previous output is about 0.97, so rankings of
20
+ activities by COG can move. `compute_complexity` returns the corrected
21
+ `cog` column; `coi` is unchanged.
22
+
23
+ ### Added
24
+ - **Complexity**
25
+ - `genepy`, also `eci_pci(mat, method="genepy")`: the GENEPY index of
26
+ Sciarra et al. (2020), following the authors' released code.
27
+ - `eci_diagnostics`: spectral gap, relation with diversity and stability
28
+ of the ECI ranking under resampling of activities (Mealy, Farmer &
29
+ Teytelboym 2019). Flags matrices where the sign convention of the ECI
30
+ is fragile.
31
+ - **Relatedness**
32
+ - `implied_rca`: implied comparative advantage of Hausmann, Stock &
33
+ Yıldırım (2022) — RCA predicted from the k most similar activities or
34
+ regions.
35
+ - `io_relatedness`: proximity from an input-output table (Essletzbichler
36
+ 2015; Fan & Lang 2000).
37
+ - `skill_relatedness`: relatedness from a matrix of flows between
38
+ activities (job switches), observed over expected, mapped to [-1, 1)
39
+ (Neffke, Otto & Weyh 2017).
40
+ - `spatial_density`: share of a region's neighbours specialized in each
41
+ activity, with user-supplied spatial weights (Bahar, Hausmann & Hidalgo
42
+ 2014; Boschma, Martín & Minondo 2017).
43
+ - `density_contributions`: which of the region's activities make another
44
+ activity feasible; the contributions add up to the density.
45
+ - `decomposed_density`: density net of region and activity fixed effects
46
+ (handles NaN cells, e.g. only the activities a region lacks).
47
+ - **Strategy** (new `strategy` module)
48
+ - `desirability_index`: weighted combination of standardized indicators
49
+ per activity, with explicit (possibly negative) weights.
50
+ - `weight_sensitivity`: how far each activity's rank moves when the
51
+ weights are redrawn (Dirichlet).
52
+ - `strategy_quadrants`: short jump / long bet / low value / avoid, with
53
+ cuts computed inside each region.
54
+ - `opportunity_alignment`: correlation, per region, between the
55
+ feasibility and the desirability of its options.
56
+ - **Policy lists** (new `policy` module) — for any set of activities (green
57
+ lists, missions, value chains)
58
+ - `list_complexity_potential`: presence and potential of each region in
59
+ each list; generalizes the Green Complexity Index and Potential of
60
+ Mealy & Teytelboym (2022), reproduced with `average="missing"`.
61
+ - `list_density`: part of the relatedness density that rests on the
62
+ activities of a list (additive).
63
+ - `missing_links`: links of a chain that are present, feasible or missing
64
+ in each region.
65
+ - `transition_risk`: exposure to a list of activities at risk, Brown
66
+ Lock-in Index and Transition Outlook (Andres et al. 2023).
67
+ - **Entry prediction** (new `prediction` module)
68
+ - `entry_targets`: binary entry target and risk set between two periods
69
+ (RCA < 0.5 → RCA ≥ 1 by default, optional minimum size).
70
+ - `validate_entry`: scores any predictor of entry — AUC, within-region
71
+ AUC, average precision, precision/recall@k, Brier — with bootstrap
72
+ intervals by region and differences to a baseline. NumPy/SciPy only.
73
+ - `build_features`, `predict_entry`, `explain_entry` (need scikit-learn):
74
+ table of features per cell, out-of-sample probability of entry by
75
+ cross-validation over regions (gradient boosting, random forest, logit
76
+ or any classifier; one model on layers or one model per activity on the
77
+ RCA vector), and permutation importance on held-out regions.
78
+ - `potential_employment`: expected size of entries, probability × arrival
79
+ size (location quotient of 1, or quantiles of past entrants).
80
+ - `examples/diversification_strategy.py`: the new tools end to end.
81
+
82
+ ### Changed
83
+ - Documentation: a step-by-step tutorial opens the reference part of both
84
+ PDFs — nine steps from the raw table to a shortlist of targets and its
85
+ out-of-sample test, each with code, the output it prints and how to read
86
+ it. It is generated by `docs/generate_tutorial.py`, which runs the code,
87
+ so the numbers in the PDF are the ones the library produces; the same
88
+ code is in `examples/tutorial.py`.
89
+ - Documentation: new sections in the English and Portuguese PDFs (density
90
+ decompositions, skill relatedness, spatial density, strategy, policy
91
+ lists, entry validation), COG formula, interpretation table, references.
92
+ - `econcomplex.relatedness.__all__` lists every function of the subpackage.
93
+ - CI installs the `ml` extra so that the prediction tests run.
94
+
3
95
  ## [1.1.0] — 2026-11-24
4
96
 
5
97
  ### Fixed
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: econcomplex
3
- Version: 1.1.0
3
+ Version: 1.2.0
4
4
  Summary: Python library for economic complexity and regional science indicators
5
5
  Author: Elton Freitas
6
6
  License-Expression: MIT
@@ -34,11 +34,13 @@ Requires-Dist: pytest-cov; extra == "dev"
34
34
  Requires-Dist: twine; extra == "dev"
35
35
  Provides-Extra: network
36
36
  Requires-Dist: networkx>=2.6; extra == "network"
37
+ Provides-Extra: ml
38
+ Requires-Dist: scikit-learn>=1.0; extra == "ml"
37
39
  Dynamic: license-file
38
40
 
39
41
  # econcomplex
40
42
 
41
- [![version](https://img.shields.io/badge/version-1.1.0-blue)](CHANGELOG.md)
43
+ [![version](https://img.shields.io/badge/version-1.2.0-blue)](CHANGELOG.md)
42
44
  [![python](https://img.shields.io/badge/python-3.10%2B-blue)](pyproject.toml)
43
45
  [![license](https://img.shields.io/badge/license-MIT-green)](LICENSE)
44
46
  [![tests](https://github.com/eltonfreitas/econcomplex/actions/workflows/tests.yml/badge.svg)](https://github.com/eltonfreitas/econcomplex/actions/workflows/tests.yml)
@@ -58,18 +60,21 @@ diffusion) that, to our knowledge, is not available in any other package.
58
60
 
59
61
  | Group | Indicators |
60
62
  |---|---|
61
- | **Complexity** | ECI / PCI through a single entry point — `eci_pci(mat, method="eigenvector" \| "reflections" \| "fitness")` — plus subnational ECI projected with an external PCI |
62
- | **Relatedness / Product Space** | Proximity (discrete, correlation, cosine), relatedness density, distance, relative relatedness (option-set z-score), co-occurrence indices, cross-space proximity between two activity spaces |
63
+ | **Complexity** | ECI / PCI through a single entry point — `eci_pci(mat, method="eigenvector" \| "reflections" \| "fitness")` — plus subnational ECI projected with an external PCI, the GENEPY index (`method="genepy"`) and diagnostics of how reliable the ECI ranking is |
64
+ | **Relatedness / Product Space** | Proximity (discrete, correlation, cosine), relatedness density, distance, relative relatedness (option-set z-score), co-occurrence indices, cross-space proximity between two activity spaces, skill relatedness from flows, spatial density, density contributions and fixed-effects decomposition, implied comparative advantage, input-output relatedness |
63
65
  | **Specialization** | Location quotient, Hachman, Krugman, Hoover specialization coefficient, export similarity |
64
66
  | **Inequality / Concentration** | Gini, locational Gini, Hoover-Gini, Hoover index, Herfindahl-Hirschman, Shannon entropy |
65
67
  | **Productivity** | PRODY, EXPY, Product Gini Index, Product Emissions Intensity Index |
66
68
  | **Patents** | Ease of recombination, modular complexity |
67
69
  | **Dynamics** | Growth rates, entry/exit tracking — matrix-pair and long-panel APIs |
68
70
  | **Outlook** | Complexity Outlook Index (COI) and Gain (COG) |
71
+ | **Strategy** | Desirability index with explicit weights, sensitivity of the ranking to the weights, feasibility × desirability quadrants, opportunity alignment |
72
+ | **Policy lists** | Presence and potential of a region in any list of activities (green lists, missions, value chains), density that rests on a list, missing links of a chain, transition risk (exposure, lock-in, outlook) |
73
+ | **Entry prediction** | Entry targets with a risk set, and out-of-sample validation of any predictor: AUC, within-region AUC, precision/recall@k, Brier, bootstrap by region; optional prediction models (gradient boosting, random forest, logit) with out-of-sample probabilities, feature importance and expected size of entries |
69
74
  | **ECI Optimization** | Stepping-stone forecast model, entry-effort matrix, exact 0–1 program for minimal-effort diversification portfolios, growth targeting (Stojkoski & Hidalgo 2026) |
70
75
  | **Strategic diffusion** | Complex-contagion calibration, five diversification strategies, optimal entry sequencing (Alshamsi, Pinheiro & Hidalgo 2018) |
71
76
 
72
- 90 public functions in total — the PDF documentation carries a complete API
77
+ 112 public functions in total — the PDF documentation carries a complete API
73
78
  reference and an interpretation guide for every indicator family.
74
79
 
75
80
  ## Installation
@@ -85,7 +90,8 @@ pip install git+https://github.com/eltonfreitas/econcomplex.git
85
90
  ```
86
91
 
87
92
  Requires Python ≥ 3.10 with `numpy ≥ 1.21` (1.x **and** 2.x supported),
88
- `pandas ≥ 1.3`, `scipy ≥ 1.9`. For local development:
93
+ `pandas ≥ 1.3`, `scipy ≥ 1.9`. The prediction models are optional and need
94
+ scikit-learn: `pip install "econcomplex[ml]"`. For local development:
89
95
 
90
96
  ```bash
91
97
  git clone https://github.com/eltonfreitas/econcomplex.git
@@ -154,6 +160,35 @@ best = ec.optimize_sequence(adj, ec.mcp(mat).loc["my_region"],
154
160
  B=fit["B"], alpha=fit["alpha"])
155
161
  ```
156
162
 
163
+ ### 4. From indicators to a strategy
164
+
165
+ ```python
166
+ # why is an activity within reach, and what is specific to the pair?
167
+ ec.density_contributions(mat, "my_region", "target_activity", phi=phi)
168
+ specific = ec.decomposed_density(density) # net of region/activity effects
169
+
170
+ # what is worth having, and how robust is that ranking to the weights?
171
+ indicators = pd.DataFrame({"pci": pci, "wage": wage})
172
+ desirability = ec.desirability_index(indicators, weights={"pci": 0.6, "wage": 0.4})
173
+ robust = ec.weight_sensitivity(indicators, seed=1)
174
+
175
+ # short jumps, long bets, low value, avoid — per region
176
+ options = ec.relatedness_density_external(mat, phi=phi)
177
+ quadrants = ec.strategy_quadrants(options, desirability)
178
+
179
+ # does a score computed at t0 predict the entries observed by t1?
180
+ target, at_risk = ec.entry_targets(ec.rca(mat_t0), ec.rca(mat_t1))
181
+ ec.validate_entry({"density": ec.density(mat_t0), "persistence": ec.rca(mat_t0)},
182
+ target, baseline="persistence", n_boot=200)
183
+
184
+ # optional (pip install "econcomplex[ml]"): a model on several layers,
185
+ # predicted out of sample, region by region
186
+ X = ec.build_features(mat_t0, {"density": ec.density(mat_t0),
187
+ "implied": ec.implied_rca(mat_t0)}, at_risk=at_risk)
188
+ prob = ec.predict_entry(X, target, model="gbm", seed=1)
189
+ ec.explain_entry(X, target, seed=1) # which layers carry the prediction
190
+ ```
191
+
157
192
  ## Data format
158
193
 
159
194
  The high-level API expects **long-format** (tidy) data — one row per
@@ -173,15 +208,20 @@ data: `df = ec.make_sample_data(n_locs=50, n_acts=30, seed=42)`.
173
208
 
174
209
  ## Documentation and examples
175
210
 
176
- - **Technical documentation (PDF)** — formulas, step-by-step usage,
211
+ - **Technical documentation (PDF)** — a step-by-step tutorial with code and
212
+ output, formulas,
177
213
  interpretation guide, and the complete API reference:
178
214
  [English](docs/econcomplex_documentation_en.pdf) ·
179
215
  [Português](docs/econcomplex_documentation_pt.pdf)
180
216
  (LaTeX sources in [docs/](docs/))
181
- - **Runnable examples**: [examples/basic_usage.py](examples/basic_usage.py)
182
- (guided tour of every indicator group) and
217
+ - **Runnable examples**: [examples/tutorial.py](examples/tutorial.py)
218
+ (the step-by-step tutorial of the PDF, from the data to a list of targets),
219
+ [examples/basic_usage.py](examples/basic_usage.py)
220
+ (guided tour of every indicator group),
183
221
  [examples/eci_optimization.py](examples/eci_optimization.py)
184
- (optimization layer end to end)
222
+ (optimization layer end to end) and
223
+ [examples/diversification_strategy.py](examples/diversification_strategy.py)
224
+ (validation of relatedness, desirability, quadrants and policy lists)
185
225
  - **In-code reference**: every function has a full NumPy-style docstring —
186
226
  `help(ec.eci_pci)`
187
227
  - **[CHANGELOG.md](CHANGELOG.md)** — release history
@@ -208,7 +248,7 @@ library recovers the canonical ECI country ranking.
208
248
  author = {Freitas, Elton},
209
249
  title = {econcomplex: economic complexity and regional science indicators in Python},
210
250
  year = {2026},
211
- version = {1.1.0},
251
+ version = {1.2.0},
212
252
  url = {https://github.com/eltonfreitas/econcomplex}
213
253
  }
214
254
  ```
@@ -1,6 +1,6 @@
1
1
  # econcomplex
2
2
 
3
- [![version](https://img.shields.io/badge/version-1.1.0-blue)](CHANGELOG.md)
3
+ [![version](https://img.shields.io/badge/version-1.2.0-blue)](CHANGELOG.md)
4
4
  [![python](https://img.shields.io/badge/python-3.10%2B-blue)](pyproject.toml)
5
5
  [![license](https://img.shields.io/badge/license-MIT-green)](LICENSE)
6
6
  [![tests](https://github.com/eltonfreitas/econcomplex/actions/workflows/tests.yml/badge.svg)](https://github.com/eltonfreitas/econcomplex/actions/workflows/tests.yml)
@@ -20,18 +20,21 @@ diffusion) that, to our knowledge, is not available in any other package.
20
20
 
21
21
  | Group | Indicators |
22
22
  |---|---|
23
- | **Complexity** | ECI / PCI through a single entry point — `eci_pci(mat, method="eigenvector" \| "reflections" \| "fitness")` — plus subnational ECI projected with an external PCI |
24
- | **Relatedness / Product Space** | Proximity (discrete, correlation, cosine), relatedness density, distance, relative relatedness (option-set z-score), co-occurrence indices, cross-space proximity between two activity spaces |
23
+ | **Complexity** | ECI / PCI through a single entry point — `eci_pci(mat, method="eigenvector" \| "reflections" \| "fitness")` — plus subnational ECI projected with an external PCI, the GENEPY index (`method="genepy"`) and diagnostics of how reliable the ECI ranking is |
24
+ | **Relatedness / Product Space** | Proximity (discrete, correlation, cosine), relatedness density, distance, relative relatedness (option-set z-score), co-occurrence indices, cross-space proximity between two activity spaces, skill relatedness from flows, spatial density, density contributions and fixed-effects decomposition, implied comparative advantage, input-output relatedness |
25
25
  | **Specialization** | Location quotient, Hachman, Krugman, Hoover specialization coefficient, export similarity |
26
26
  | **Inequality / Concentration** | Gini, locational Gini, Hoover-Gini, Hoover index, Herfindahl-Hirschman, Shannon entropy |
27
27
  | **Productivity** | PRODY, EXPY, Product Gini Index, Product Emissions Intensity Index |
28
28
  | **Patents** | Ease of recombination, modular complexity |
29
29
  | **Dynamics** | Growth rates, entry/exit tracking — matrix-pair and long-panel APIs |
30
30
  | **Outlook** | Complexity Outlook Index (COI) and Gain (COG) |
31
+ | **Strategy** | Desirability index with explicit weights, sensitivity of the ranking to the weights, feasibility × desirability quadrants, opportunity alignment |
32
+ | **Policy lists** | Presence and potential of a region in any list of activities (green lists, missions, value chains), density that rests on a list, missing links of a chain, transition risk (exposure, lock-in, outlook) |
33
+ | **Entry prediction** | Entry targets with a risk set, and out-of-sample validation of any predictor: AUC, within-region AUC, precision/recall@k, Brier, bootstrap by region; optional prediction models (gradient boosting, random forest, logit) with out-of-sample probabilities, feature importance and expected size of entries |
31
34
  | **ECI Optimization** | Stepping-stone forecast model, entry-effort matrix, exact 0–1 program for minimal-effort diversification portfolios, growth targeting (Stojkoski & Hidalgo 2026) |
32
35
  | **Strategic diffusion** | Complex-contagion calibration, five diversification strategies, optimal entry sequencing (Alshamsi, Pinheiro & Hidalgo 2018) |
33
36
 
34
- 90 public functions in total — the PDF documentation carries a complete API
37
+ 112 public functions in total — the PDF documentation carries a complete API
35
38
  reference and an interpretation guide for every indicator family.
36
39
 
37
40
  ## Installation
@@ -47,7 +50,8 @@ pip install git+https://github.com/eltonfreitas/econcomplex.git
47
50
  ```
48
51
 
49
52
  Requires Python ≥ 3.10 with `numpy ≥ 1.21` (1.x **and** 2.x supported),
50
- `pandas ≥ 1.3`, `scipy ≥ 1.9`. For local development:
53
+ `pandas ≥ 1.3`, `scipy ≥ 1.9`. The prediction models are optional and need
54
+ scikit-learn: `pip install "econcomplex[ml]"`. For local development:
51
55
 
52
56
  ```bash
53
57
  git clone https://github.com/eltonfreitas/econcomplex.git
@@ -116,6 +120,35 @@ best = ec.optimize_sequence(adj, ec.mcp(mat).loc["my_region"],
116
120
  B=fit["B"], alpha=fit["alpha"])
117
121
  ```
118
122
 
123
+ ### 4. From indicators to a strategy
124
+
125
+ ```python
126
+ # why is an activity within reach, and what is specific to the pair?
127
+ ec.density_contributions(mat, "my_region", "target_activity", phi=phi)
128
+ specific = ec.decomposed_density(density) # net of region/activity effects
129
+
130
+ # what is worth having, and how robust is that ranking to the weights?
131
+ indicators = pd.DataFrame({"pci": pci, "wage": wage})
132
+ desirability = ec.desirability_index(indicators, weights={"pci": 0.6, "wage": 0.4})
133
+ robust = ec.weight_sensitivity(indicators, seed=1)
134
+
135
+ # short jumps, long bets, low value, avoid — per region
136
+ options = ec.relatedness_density_external(mat, phi=phi)
137
+ quadrants = ec.strategy_quadrants(options, desirability)
138
+
139
+ # does a score computed at t0 predict the entries observed by t1?
140
+ target, at_risk = ec.entry_targets(ec.rca(mat_t0), ec.rca(mat_t1))
141
+ ec.validate_entry({"density": ec.density(mat_t0), "persistence": ec.rca(mat_t0)},
142
+ target, baseline="persistence", n_boot=200)
143
+
144
+ # optional (pip install "econcomplex[ml]"): a model on several layers,
145
+ # predicted out of sample, region by region
146
+ X = ec.build_features(mat_t0, {"density": ec.density(mat_t0),
147
+ "implied": ec.implied_rca(mat_t0)}, at_risk=at_risk)
148
+ prob = ec.predict_entry(X, target, model="gbm", seed=1)
149
+ ec.explain_entry(X, target, seed=1) # which layers carry the prediction
150
+ ```
151
+
119
152
  ## Data format
120
153
 
121
154
  The high-level API expects **long-format** (tidy) data — one row per
@@ -135,15 +168,20 @@ data: `df = ec.make_sample_data(n_locs=50, n_acts=30, seed=42)`.
135
168
 
136
169
  ## Documentation and examples
137
170
 
138
- - **Technical documentation (PDF)** — formulas, step-by-step usage,
171
+ - **Technical documentation (PDF)** — a step-by-step tutorial with code and
172
+ output, formulas,
139
173
  interpretation guide, and the complete API reference:
140
174
  [English](docs/econcomplex_documentation_en.pdf) ·
141
175
  [Português](docs/econcomplex_documentation_pt.pdf)
142
176
  (LaTeX sources in [docs/](docs/))
143
- - **Runnable examples**: [examples/basic_usage.py](examples/basic_usage.py)
144
- (guided tour of every indicator group) and
177
+ - **Runnable examples**: [examples/tutorial.py](examples/tutorial.py)
178
+ (the step-by-step tutorial of the PDF, from the data to a list of targets),
179
+ [examples/basic_usage.py](examples/basic_usage.py)
180
+ (guided tour of every indicator group),
145
181
  [examples/eci_optimization.py](examples/eci_optimization.py)
146
- (optimization layer end to end)
182
+ (optimization layer end to end) and
183
+ [examples/diversification_strategy.py](examples/diversification_strategy.py)
184
+ (validation of relatedness, desirability, quadrants and policy lists)
147
185
  - **In-code reference**: every function has a full NumPy-style docstring —
148
186
  `help(ec.eci_pci)`
149
187
  - **[CHANGELOG.md](CHANGELOG.md)** — release history
@@ -170,7 +208,7 @@ library recovers the canonical ECI country ranking.
170
208
  author = {Freitas, Elton},
171
209
  title = {econcomplex: economic complexity and regional science indicators in Python},
172
210
  year = {2026},
173
- version = {1.1.0},
211
+ version = {1.2.0},
174
212
  url = {https://github.com/eltonfreitas/econcomplex}
175
213
  }
176
214
  ```
@@ -1,6 +1,6 @@
1
1
  # econcomplex
2
2
 
3
- [![version](https://img.shields.io/badge/vers%C3%A3o-1.1.0-blue)](CHANGELOG.md)
3
+ [![version](https://img.shields.io/badge/vers%C3%A3o-1.2.0-blue)](CHANGELOG.md)
4
4
  [![python](https://img.shields.io/badge/python-3.10%2B-blue)](pyproject.toml)
5
5
  [![license](https://img.shields.io/badge/licen%C3%A7a-MIT-green)](LICENSE)
6
6
  [![tests](https://github.com/eltonfreitas/econcomplex/actions/workflows/tests.yml/badge.svg)](https://github.com/eltonfreitas/econcomplex/actions/workflows/tests.yml)
@@ -20,18 +20,21 @@ difusão estratégica) que, até onde sabemos, não existe em nenhum outro pacot
20
20
 
21
21
  | Grupo | Indicadores |
22
22
  |---|---|
23
- | **Complexidade** | ECI / PCI por uma porta de entrada única — `eci_pci(mat, method="eigenvector" \| "reflections" \| "fitness")` — além de ECI subnacional projetado com PCI externo |
24
- | **Relatedness / Product Space** | Proximidade (discreta, correlação, cosseno), densidade de relatedness, distância, relatedness relativa (z-score no option set), índices de coocorrência, proximidade cross-space entre dois espaços de atividades |
23
+ | **Complexidade** | ECI / PCI por uma porta de entrada única — `eci_pci(mat, method="eigenvector" \| "reflections" \| "fitness")` — além de ECI subnacional projetado com PCI externo, o índice GENEPY (`method="genepy"`) e diagnósticos de confiabilidade do ranking de ECI |
24
+ | **Relatedness / Product Space** | Proximidade (discreta, correlação, cosseno), densidade de relatedness, distância, relatedness relativa (z-score no option set), índices de coocorrência, proximidade cross-space entre dois espaços de atividades, skill relatedness por fluxos, densidade espacial, contribuições e decomposição da densidade, vantagem comparativa implícita, relatedness por insumo-produto |
25
25
  | **Especialização** | Quociente locacional, Hachman, Krugman, coeficiente de especialização de Hoover, similaridade de exportações |
26
26
  | **Desigualdade / Concentração** | Gini, Gini locacional, Hoover-Gini, índice de Hoover, Herfindahl-Hirschman, entropia de Shannon |
27
27
  | **Produtividade** | PRODY, EXPY, Product Gini Index, Product Emissions Intensity Index |
28
28
  | **Patentes** | Facilidade de recombinação, complexidade modular |
29
29
  | **Dinâmica** | Taxas de crescimento, rastreamento de entrada/saída — APIs por pares de matrizes e por painel longo |
30
30
  | **Outlook** | Complexity Outlook Index (COI) e Gain (COG) |
31
+ | **Estratégia** | Índice de desejabilidade com pesos explícitos, sensibilidade do ranking aos pesos, quadrantes viabilidade × desejabilidade, alinhamento de oportunidades |
32
+ | **Listas de política** | Presença e potencial da região em qualquer lista de atividades (listas verdes, missões, cadeias), densidade apoiada numa lista, elos ausentes de uma cadeia, risco de transição (exposição, lock-in, perspectiva) |
33
+ | **Previsão de entradas** | Alvos de entrada com conjunto em risco e validação fora da amostra de qualquer preditor: AUC, AUC intra-região, precisão/revocação@k, Brier, bootstrap por região; modelos de previsão opcionais (gradient boosting, floresta aleatória, logit) com probabilidades fora da amostra, importância dos atributos e tamanho esperado das entradas |
31
34
  | **Otimização de ECI** | Modelo de previsão com steppingstone, matriz de esforço de entrada, programa 0–1 exato para portfólios de diversificação de menor esforço, metas de crescimento (Stojkoski & Hidalgo 2026) |
32
35
  | **Difusão estratégica** | Calibração de contágio complexo, cinco estratégias de diversificação, sequenciamento ótimo de entrada (Alshamsi, Pinheiro & Hidalgo 2018) |
33
36
 
34
- São 90 funções públicas — a documentação em PDF traz a referência completa da
37
+ São 112 funções públicas — a documentação em PDF traz a referência completa da
35
38
  API e um guia de interpretação para cada família de indicadores.
36
39
 
37
40
  ## Instalação
@@ -47,7 +50,8 @@ pip install git+https://github.com/eltonfreitas/econcomplex.git
47
50
  ```
48
51
 
49
52
  Exige Python ≥ 3.10 com `numpy ≥ 1.21` (compatível com 1.x **e** 2.x),
50
- `pandas ≥ 1.3`, `scipy ≥ 1.9`. Para desenvolvimento local:
53
+ `pandas ≥ 1.3`, `scipy ≥ 1.9`. Os modelos de previsão são opcionais e exigem
54
+ o scikit-learn: `pip install "econcomplex[ml]"`. Para desenvolvimento local:
51
55
 
52
56
  ```bash
53
57
  git clone https://github.com/eltonfreitas/econcomplex.git
@@ -117,6 +121,35 @@ otimo = ec.optimize_sequence(adj, ec.mcp(mat).loc["minha_regiao"],
117
121
  B=fit["B"], alpha=fit["alpha"])
118
122
  ```
119
123
 
124
+ ### 4. Dos indicadores à estratégia
125
+
126
+ ```python
127
+ # por que uma atividade está ao alcance, e o que é específico do par?
128
+ ec.density_contributions(mat, "minha_regiao", "atividade_alvo", phi=phi)
129
+ especifica = ec.decomposed_density(density) # líquida dos efeitos de região/atividade
130
+
131
+ # o que vale a pena ter, e quão robusto é esse ranking aos pesos?
132
+ indicadores = pd.DataFrame({"pci": pci, "salario": salario})
133
+ desejabilidade = ec.desirability_index(indicadores, weights={"pci": 0.6, "salario": 0.4})
134
+ robustez = ec.weight_sensitivity(indicadores, seed=1)
135
+
136
+ # saltos curtos, apostas longas, baixo valor, evitar — por região
137
+ opcoes = ec.relatedness_density_external(mat, phi=phi)
138
+ quadrantes = ec.strategy_quadrants(opcoes, desejabilidade)
139
+
140
+ # um escore calculado em t0 prevê as entradas observadas até t1?
141
+ alvo, em_risco = ec.entry_targets(ec.rca(mat_t0), ec.rca(mat_t1))
142
+ ec.validate_entry({"densidade": ec.density(mat_t0), "persistencia": ec.rca(mat_t0)},
143
+ alvo, baseline="persistencia", n_boot=200)
144
+
145
+ # opcional (pip install "econcomplex[ml]"): um modelo com várias camadas,
146
+ # previsto fora da amostra, região por região
147
+ X = ec.build_features(mat_t0, {"densidade": ec.density(mat_t0),
148
+ "implicita": ec.implied_rca(mat_t0)}, at_risk=em_risco)
149
+ prob = ec.predict_entry(X, alvo, model="gbm", seed=1)
150
+ ec.explain_entry(X, alvo, seed=1) # quais camadas sustentam a previsão
151
+ ```
152
+
120
153
  ## Formato dos dados
121
154
 
122
155
  A API de alto nível espera dados em **formato longo** (tidy) — uma linha por
@@ -136,15 +169,20 @@ experimentar sem dados: `df = ec.make_sample_data(n_locs=50, n_acts=30, seed=42)
136
169
 
137
170
  ## Documentação e exemplos
138
171
 
139
- - **Documentação técnica (PDF)** — fórmulas, passo a passo de uso, guia de
172
+ - **Documentação técnica (PDF)** — tutorial passo a passo com código e
173
+ saída, fórmulas, guia de
140
174
  interpretação e a referência completa da API:
141
175
  [Português](docs/econcomplex_documentation_pt.pdf) ·
142
176
  [English](docs/econcomplex_documentation_en.pdf)
143
177
  (fontes LaTeX em [docs/](docs/))
144
- - **Exemplos executáveis**: [examples/basic_usage.py](examples/basic_usage.py)
145
- (tour guiado por todos os grupos de indicadores) e
178
+ - **Exemplos executáveis**: [examples/tutorial.py](examples/tutorial.py)
179
+ (o tutorial passo a passo do PDF, dos dados a uma lista de alvos),
180
+ [examples/basic_usage.py](examples/basic_usage.py)
181
+ (tour guiado por todos os grupos de indicadores),
146
182
  [examples/eci_optimization.py](examples/eci_optimization.py)
147
- (camada de otimização de ponta a ponta)
183
+ (camada de otimização de ponta a ponta) e
184
+ [examples/diversification_strategy.py](examples/diversification_strategy.py)
185
+ (validação da relatedness, desejabilidade, quadrantes e listas de política)
148
186
  - **Referência no código**: toda função tem docstring completo no estilo
149
187
  NumPy — `help(ec.eci_pci)`
150
188
  - **[CHANGELOG.md](CHANGELOG.md)** — histórico de versões
@@ -171,7 +209,7 @@ recupera o ranking canônico de ECI dos países.
171
209
  author = {Freitas, Elton},
172
210
  title = {econcomplex: economic complexity and regional science indicators in Python},
173
211
  year = {2026},
174
- version = {1.1.0},
212
+ version = {1.2.0},
175
213
  url = {https://github.com/eltonfreitas/econcomplex}
176
214
  }
177
215
  ```
@@ -31,6 +31,8 @@
31
31
  \texttt{\footnotesize mor\_activities(mat, use\_rca=True, threshold=1.0, steps=19)} & {\small Method of Reflections -- activity/technology side only.} \\[2pt]
32
32
  \texttt{\footnotesize fitness\_complexity(mat, use\_rca=True, threshold=1.0, iterations=20, extremality=1.0, tol=1e-10, log\_fitness=False)} & {\small Fitness-Complexity algorithm.} \\[2pt]
33
33
  \texttt{\footnotesize subnational\_eci(mat, pci\_external, use\_rca=True, threshold=1.0, standardize=True)} & {\small Subnational ECI using an externally supplied PCI vector.} \\[2pt]
34
+ \texttt{\footnotesize genepy(mat, use\_rca=True, threshold=1.0)} & {\small GENEPY index of regions and activities (advanced implementation; prefer ``eci\_pci(mat, method="genepy")``, which adds the automatic trimming of degenerate units).} \\[2pt]
35
+ \texttt{\footnotesize eci\_diagnostics(mat, n\_boot=100, share=0.8, use\_rca=True, threshold=1.0, seed=None)} & {\small How much can the ECI ranking of this matrix be trusted?} \\[2pt]
34
36
  \bottomrule
35
37
  \end{longtable}
36
38
 
@@ -52,6 +54,12 @@
52
54
  \texttt{\footnotesize relatedness\_density\_internal(mat, phi=None, use\_rca=True, threshold=1.0, proximity\_method='max', percent=True)} & {\small Internal relatedness density: density values for activities the region ALREADY has (M\_{rc} = 1).} \\[2pt]
53
55
  \texttt{\footnotesize relatedness\_density\_external(mat, phi=None, use\_rca=True, threshold=1.0, proximity\_method='max', percent=True)} & {\small External relatedness density: density values for activities the region does NOT yet have (M\_{rc} = 0).} \\[2pt]
54
56
  \texttt{\footnotesize relative\_relatedness(mat, phi=None, use\_rca=True, threshold=1.0, proximity\_method='max')} & {\small Relative relatedness (Pinheiro et al.} \\[2pt]
57
+ \texttt{\footnotesize density\_contributions(mat, region, activity, phi=None, use\_rca=True, threshold=1.0, proximity\_method='max', percent=True)} & {\small Which activities of a region make another activity feasible there.} \\[2pt]
58
+ \texttt{\footnotesize decomposed\_density(density, tol=1e-10, max\_iter=1000)} & {\small Relatedness density net of region and activity fixed effects.} \\[2pt]
59
+ \texttt{\footnotesize skill\_relatedness(flows, symmetric=False, exclude\_diagonal=True, normalize=True)} & {\small Skill relatedness between activities from a matrix of flows.} \\[2pt]
60
+ \texttt{\footnotesize spatial\_density(mat, W, use\_rca=True, threshold=1.0)} & {\small Share of a region's neighbours that are specialized in each activity.} \\[2pt]
61
+ \texttt{\footnotesize implied\_rca(mat, space='activity', k=None, cap=5.0, use\_rca=True)} & {\small Implied comparative advantage (Hausmann, Stock \& Yıldırım 2022).} \\[2pt]
62
+ \texttt{\footnotesize io\_relatedness(Z, shares='sales', method='mean')} & {\small Relatedness between industries from an input-output table.} \\[2pt]
55
63
  \texttt{\footnotesize co\_occurrence(mat, diagonal=False)} & {\small Co-occurrence matrix: number of times two activities appear together across regions/events.} \\[2pt]
56
64
  \texttt{\footnotesize relatedness\_index(mat, method='cosine', diagonal=False)} & {\small Pairwise relatedness index between activities from co-occurrence.} \\[2pt]
57
65
  \texttt{\footnotesize z\_score\_novelty(incidence)} & {\small Z-score of technological novelty (atypicality of co-occurrence).} \\[2pt]
@@ -167,6 +175,44 @@
167
175
  \bottomrule
168
176
  \end{longtable}
169
177
 
178
+ \subsection{\texttt{strategy} --- Strategy: Desirability and Quadrants}
179
+ \begin{longtable}{>{\raggedright\arraybackslash}p{9.2cm} >{\raggedright\arraybackslash}p{7.0cm}}
180
+ \toprule
181
+ \textbf{Function} & \textbf{Description} \\
182
+ \midrule\endhead
183
+ \texttt{\footnotesize desirability\_index(indicators, weights=None, standardize='z')} & {\small Weighted combination of indicators of how desirable each activity is.} \\[2pt]
184
+ \texttt{\footnotesize weight\_sensitivity(indicators, weights=None, standardize='z', n\_draws=1000, concentration=1.0, top=10, seed=None)} & {\small Stability of the desirability ranking when the weights change.} \\[2pt]
185
+ \texttt{\footnotesize strategy\_quadrants(feasibility, desirability, by\_region=True, cut='median')} & {\small Classify each region's options by feasibility and desirability.} \\[2pt]
186
+ \texttt{\footnotesize opportunity\_alignment(feasibility, desirability, method='spearman', min\_options=3)} & {\small Are a region's nearby opportunities also its valuable ones?} \\[2pt]
187
+ \bottomrule
188
+ \end{longtable}
189
+
190
+ \subsection{\texttt{policy} --- Policy Lists}
191
+ \begin{longtable}{>{\raggedright\arraybackslash}p{9.2cm} >{\raggedright\arraybackslash}p{7.0cm}}
192
+ \toprule
193
+ \textbf{Function} & \textbf{Description} \\
194
+ \midrule\endhead
195
+ \texttt{\footnotesize list\_complexity\_potential(mat, value, feasibility, lists, use\_rca=True, threshold=1.0, average='list')} & {\small What a region has, and could reach, within a list of activities.} \\[2pt]
196
+ \texttt{\footnotesize list\_density(mat, lists, phi=None, use\_rca=True, threshold=1.0, proximity\_method='max', percent=True)} & {\small Part of the relatedness density that comes from each list.} \\[2pt]
197
+ \texttt{\footnotesize missing\_links(mat, links, feasibility, cut, use\_rca=True, threshold=1.0)} & {\small Which links of a chain a region has, could reach, or lacks.} \\[2pt]
198
+ \texttt{\footnotesize transition\_risk(mat, exposed, pci=None, targets=None, phi=None, use\_rca=True, threshold=1.0, proximity\_method='max')} & {\small Exposure of each region to a list of activities at risk, and how easily it can move out of them.} \\[2pt]
199
+ \bottomrule
200
+ \end{longtable}
201
+
202
+ \subsection{\texttt{prediction} --- Entry Prediction and Validation}
203
+ \begin{longtable}{>{\raggedright\arraybackslash}p{9.2cm} >{\raggedright\arraybackslash}p{7.0cm}}
204
+ \toprule
205
+ \textbf{Function} & \textbf{Description} \\
206
+ \midrule\endhead
207
+ \texttt{\footnotesize entry\_targets(rca\_t0, rca\_t1, values\_t1=None, lower=0.5, upper=1.0, min\_value=None)} & {\small Binary entry target and risk set between two periods.} \\[2pt]
208
+ \texttt{\footnotesize validate\_entry(scores, target, k=(10, 20), baseline=None, n\_boot=0, seed=None)} & {\small How well do scores computed at t0 predict the entries observed by t1?} \\[2pt]
209
+ \texttt{\footnotesize potential\_employment(prob, values, arrival='lq1', entrants=None, quantiles=(0.25, 0.5, 0.75))} & {\small Expected size of the activities a region may enter.} \\[2pt]
210
+ \texttt{\footnotesize build\_features(mat, layers=None, at\_risk=None, region\_vars=None, activity\_vars=None, controls=True, use\_rca=True, threshold=1.0)} & {\small Table of features for each (region, activity) cell.} \\[2pt]
211
+ \texttt{\footnotesize predict\_entry(features, target, model='gbm', mode='layers', new\_features=None, groups=None, n\_splits=5, calibrate=False, min\_entries=5, seed=None, return\_model=False)} & {\small Predicted probability of entry, out of sample.} \\[2pt]
212
+ \texttt{\footnotesize explain\_entry(features, target, model='gbm', groups=None, n\_splits=5, n\_repeats=10, alpha=0.05, seed=None)} & {\small Which features carry the prediction of entry, out of sample.} \\[2pt]
213
+ \bottomrule
214
+ \end{longtable}
215
+
170
216
  \subsection{\texttt{pipeline} --- Unified Pipeline}
171
217
  \begin{longtable}{>{\raggedright\arraybackslash}p{9.2cm} >{\raggedright\arraybackslash}p{7.0cm}}
172
218
  \toprule
@@ -31,6 +31,8 @@
31
31
  \texttt{\footnotesize mor\_activities(mat, use\_rca=True, threshold=1.0, steps=19)} & {\small Reflex\~{o}es apenas do lado das atividades.} \\[2pt]
32
32
  \texttt{\footnotesize fitness\_complexity(mat, use\_rca=True, threshold=1.0, iterations=20, extremality=1.0, tol=1e-10, log\_fitness=False)} & {\small Algoritmo Fitness--Complexity (Tacchella et al.\ 2012).} \\[2pt]
33
33
  \texttt{\footnotesize subnational\_eci(mat, pci\_external, use\_rca=True, threshold=1.0, standardize=True)} & {\small ECI subnacional projetado com PCI externo.} \\[2pt]
34
+ \texttt{\footnotesize genepy(mat, use\_rca=True, threshold=1.0)} & {\small GENEPY (Sciarra et al. 2020): combina os dois primeiros autovetores da proximidade entre regi\~{o}es.} \\[2pt]
35
+ \texttt{\footnotesize eci\_diagnostics(mat, n\_boot=100, share=0.8, use\_rca=True, threshold=1.0, seed=None)} & {\small Diagn\'{o}sticos do ECI: gap espectral, rela\c{c}\~{a}o com a diversidade e estabilidade do ranking.} \\[2pt]
34
36
  \bottomrule
35
37
  \end{longtable}
36
38
 
@@ -52,6 +54,12 @@
52
54
  \texttt{\footnotesize relatedness\_density\_internal(mat, phi=None, use\_rca=True, threshold=1.0, proximity\_method='max', percent=True)} & {\small Densidade restrita \`{a}s atividades j\'{a} presentes.} \\[2pt]
53
55
  \texttt{\footnotesize relatedness\_density\_external(mat, phi=None, use\_rca=True, threshold=1.0, proximity\_method='max', percent=True)} & {\small Densidade restrita \`{a}s atividades ausentes.} \\[2pt]
54
56
  \texttt{\footnotesize relative\_relatedness(mat, phi=None, use\_rca=True, threshold=1.0, proximity\_method='max')} & {\small Relatedness relativa: z-score no option set (Pinheiro et al.\ 2022).} \\[2pt]
57
+ \texttt{\footnotesize density\_contributions(mat, region, activity, phi=None, use\_rca=True, threshold=1.0, proximity\_method='max', percent=True)} & {\small Contribui\c{c}\~{a}o de cada atividade presente para a densidade de um par (regi\~{a}o, atividade).} \\[2pt]
58
+ \texttt{\footnotesize decomposed\_density(density, tol=1e-10, max\_iter=1000)} & {\small Densidade l\'{i}quida dos efeitos fixos de regi\~{a}o e de atividade.} \\[2pt]
59
+ \texttt{\footnotesize skill\_relatedness(flows, symmetric=False, exclude\_diagonal=True, normalize=True)} & {\small Relatedness por fluxos entre atividades (ex.: trocas de emprego), observado sobre esperado.} \\[2pt]
60
+ \texttt{\footnotesize spatial\_density(mat, W, use\_rca=True, threshold=1.0)} & {\small Parcela dos vizinhos especializados em cada atividade, com pesos espaciais do usu\'{a}rio.} \\[2pt]
61
+ \texttt{\footnotesize implied\_rca(mat, space='activity', k=None, cap=5.0, use\_rca=True)} & {\small VCR impl\'{i}cita (Hausmann, Stock \& Y{\i}ld{\i}r{\i}m 2022): VCR esperada a partir das k unidades mais parecidas.} \\[2pt]
62
+ \texttt{\footnotesize io\_relatedness(Z, shares='sales', method='mean')} & {\small Relatedness por insumo-produto: participa\c{c}\~{o}es nas vendas e compras entre setores.} \\[2pt]
55
63
  \texttt{\footnotesize co\_occurrence(mat, diagonal=False)} & {\small Matriz de coocorr\^{e}ncia entre atividades.} \\[2pt]
56
64
  \texttt{\footnotesize relatedness\_index(mat, method='cosine', diagonal=False)} & {\small \'{I}ndice de relatedness por coocorr\^{e}ncia (probabilidade, associa\c{c}\~{a}o, cosseno, Jaccard).} \\[2pt]
57
65
  \texttt{\footnotesize z\_score\_novelty(incidence)} & {\small Z-score de novidade (atipicidade da coocorr\^{e}ncia).} \\[2pt]
@@ -167,6 +175,44 @@
167
175
  \bottomrule
168
176
  \end{longtable}
169
177
 
178
+ \subsection{\texttt{strategy} --- Estrat\'{e}gia: Desejabilidade e Quadrantes}
179
+ \begin{longtable}{>{\raggedright\arraybackslash}p{9.2cm} >{\raggedright\arraybackslash}p{7.0cm}}
180
+ \toprule
181
+ \textbf{Fun\c{c}\~{a}o} & \textbf{Descri\c{c}\~{a}o} \\
182
+ \midrule\endhead
183
+ \texttt{\footnotesize desirability\_index(indicators, weights=None, standardize='z')} & {\small \'{I}ndice de desejabilidade: m\'{e}dia ponderada de indicadores padronizados por atividade.} \\[2pt]
184
+ \texttt{\footnotesize weight\_sensitivity(indicators, weights=None, standardize='z', n\_draws=1000, concentration=1.0, top=10, seed=None)} & {\small Estabilidade do ranking de desejabilidade sob pesos sorteados (Dirichlet).} \\[2pt]
185
+ \texttt{\footnotesize strategy\_quadrants(feasibility, desirability, by\_region=True, cut='median')} & {\small Classifica as op\c{c}\~{o}es de cada regi\~{a}o nos quadrantes viabilidade $\times$ desejabilidade.} \\[2pt]
186
+ \texttt{\footnotesize opportunity\_alignment(feasibility, desirability, method='spearman', min\_options=3)} & {\small Correla\c{c}\~{a}o, por regi\~{a}o, entre viabilidade e desejabilidade das suas op\c{c}\~{o}es.} \\[2pt]
187
+ \bottomrule
188
+ \end{longtable}
189
+
190
+ \subsection{\texttt{policy} --- Listas de Pol\'{i}tica}
191
+ \begin{longtable}{>{\raggedright\arraybackslash}p{9.2cm} >{\raggedright\arraybackslash}p{7.0cm}}
192
+ \toprule
193
+ \textbf{Fun\c{c}\~{a}o} & \textbf{Descri\c{c}\~{a}o} \\
194
+ \midrule\endhead
195
+ \texttt{\footnotesize list\_complexity\_potential(mat, value, feasibility, lists, use\_rca=True, threshold=1.0, average='list')} & {\small Presen\c{c}a e potencial de cada regi\~{a}o em listas de atividades (generaliza GCI/GCP).} \\[2pt]
196
+ \texttt{\footnotesize list\_density(mat, lists, phi=None, use\_rca=True, threshold=1.0, proximity\_method='max', percent=True)} & {\small Parcela da densidade que vem das atividades de cada lista.} \\[2pt]
197
+ \texttt{\footnotesize missing\_links(mat, links, feasibility, cut, use\_rca=True, threshold=1.0)} & {\small Elos presentes, vi\'{a}veis e ausentes de uma cadeia, por regi\~{a}o.} \\[2pt]
198
+ \texttt{\footnotesize transition\_risk(mat, exposed, pci=None, targets=None, phi=None, use\_rca=True, threshold=1.0, proximity\_method='max')} & {\small Exposi\c{c}\~{a}o a atividades em risco, lock-in e perspectiva de transi\c{c}\~{a}o (Andres et al. 2023).} \\[2pt]
199
+ \bottomrule
200
+ \end{longtable}
201
+
202
+ \subsection{\texttt{prediction} --- Previs\~{a}o de Entradas e Valida\c{c}\~{a}o}
203
+ \begin{longtable}{>{\raggedright\arraybackslash}p{9.2cm} >{\raggedright\arraybackslash}p{7.0cm}}
204
+ \toprule
205
+ \textbf{Fun\c{c}\~{a}o} & \textbf{Descri\c{c}\~{a}o} \\
206
+ \midrule\endhead
207
+ \texttt{\footnotesize entry\_targets(rca\_t0, rca\_t1, values\_t1=None, lower=0.5, upper=1.0, min\_value=None)} & {\small Alvo bin\'{a}rio de entrada e conjunto em risco entre dois per\'{i}odos.} \\[2pt]
208
+ \texttt{\footnotesize validate\_entry(scores, target, k=(10, 20), baseline=None, n\_boot=0, seed=None)} & {\small Valida preditores de entrada: AUC, AUC intra-regi\~{a}o, precis\~{a}o/revoca\c{c}\~{a}o em k, Brier, bootstrap.} \\[2pt]
209
+ \texttt{\footnotesize potential\_employment(prob, values, arrival='lq1', entrants=None, quantiles=(0.25, 0.5, 0.75))} & {\small Tamanho esperado das entradas: probabilidade $\times$ tamanho de chegada (QL = 1 ou quantis de entrantes).} \\[2pt]
210
+ \texttt{\footnotesize build\_features(mat, layers=None, at\_risk=None, region\_vars=None, activity\_vars=None, controls=True, use\_rca=True, threshold=1.0)} & {\small Tabela de atributos por c\'{e}lula (regi\~{a}o, atividade): camadas de densidade e controles.} \\[2pt]
211
+ \texttt{\footnotesize predict\_entry(features, target, model='gbm', mode='layers', new\_features=None, groups=None, n\_splits=5, calibrate=False, min\_entries=5, seed=None, return\_model=False)} & {\small Probabilidade de entrada fora da amostra (gradient boosting, floresta, logit); exige scikit-learn.} \\[2pt]
212
+ \texttt{\footnotesize explain\_entry(features, target, model='gbm', groups=None, n\_splits=5, n\_repeats=10, alpha=0.05, seed=None)} & {\small Import\^{a}ncia dos atributos por permuta\c{c}\~{a}o em regi\~{o}es fora do treino, com p-valor.} \\[2pt]
213
+ \bottomrule
214
+ \end{longtable}
215
+
170
216
  \subsection{\texttt{pipeline} --- Pipeline Unificado}
171
217
  \begin{longtable}{>{\raggedright\arraybackslash}p{9.2cm} >{\raggedright\arraybackslash}p{7.0cm}}
172
218
  \toprule