The FitnEss, The Relatedness and The other MetrIcs
fermi is a modular Python framework for analyzing the main Economic Complexity metrics and features.
It provides tools to explore the hidden structure of economies through:
- π Matrix preprocessing: raw cleaning, sparse conversion, Comparative advantage RCA/ICA, transformation and thresholding.
- π§ Fitness & complexity: compute Fitness, Complexity ECI, PCI and other metrics via multiple methods.
- π Relatedness metrics: product space, taxonomy, assist matrix.
- π Prediction models: GDP forecasting, density models, XGBoost.
- β Validation metrics: AUC, confusion matrix, prediction@k.
β οΈ Requires Python β₯ 3.0 To correnctly install and use the package, you need to have
numpy β₯ 1.24
pandas β₯ 1.5
scikit-learn β₯ 1.2
scipy β₯ 1.9
matplotlib β₯ 3.5
seaborn
bokeh β₯ 2.4
tqdm
networkx β₯ 2.6
bicm β₯ 3.3.1To install fermi directly from PyPI in a virtual environment:
python -m venv fermi-env
source fermi-env/bin/activate # or fermi-env\Scripts\activate on Windows
pip install fermi-crefTo use fermi on Colab, you can install it directly from PyPI with:
!pip install fermi-crefThe main module to generate an Economic Complexity object and initialize it (with a biadjacency matrix):
import fermi
myefc = fermi.efc()
myefc.load(my_biadjacency_matrix, *possible kwargs*)
To compute the Revealed Comparative Advantage (Balassa index) and binarize its value
myefc.compute_rca().binarize()
To compute the Fitness and the Complexity (using the original [Tacchella2012] algorithm)
fitness, complexity = myefc.get_fitness_complexity()
To compute the diversification and the ubiquity
div, ubi = myefc.get_diversification_ubiquity()
To compute the ECI index (using the eigenvalue method)
eci, pci = myefc.get_eci_pci()
The module to generate cooccurrences and similar relatedness measures is
myproj = fermi.RelatednessMetrics()
myproj.load(my_biadjacency_matrix, *possible kwargs*)
The cooccurrence can be evaluated using
relatedness = myproj.get_projection(projection_method="cooccurrence")
validated_relatedness, validated_values = myproj.get_bicm_projection(projection_method="cooccurrence", validation_method="fdr")
See a more detailed description in the API in the documentation.
If you use the fermi modules, please cite its location on Github
https://github.com/EFC-data/fermi
[Tacchella2018] Tacchella A., Mazzilli D., Pietronero L. A dynamical systems approach to gross domestic product forecasting. Nature Phys 14, 861β865 (2018)
Authors: CREF Team
We gratefully acknowledge the invaluable contributions, support, and foundational code provided by Andrea Tacchella, Emanuele Pugliese, Dario Mazzilli, and Andrea Zaccaria.