ectools is a collection of the Python tools used to do the calculations in these Economic Complexity papers:
I plan to release most or ideally all of the code publicly, and will incrementally add it to this repository. For the moment the code is simple enough that the docstrings should cover it. Please contact me for any queries regarding its use or any bugs that you may find.
At the moment, the repository contains:
- fc: Implementation of the Fitness-Complexity algorithm, a tied ranking algorithm, and the computations of RCA (Revealed Comparative Advantage following Ballassa) and logPRODY.
- SPSb: Implementation of the SPSb and Velocity SPSb algorithms (based on the convergence with NWKR proven in one of the papers above), and many utilities for backtesting, metaparameter selection, model stacking and error evaluation.
- NWKR: An implementation of the Nadaraya-Watson Kernel Regression in the style of scikit-learn.
Compared to that found in scikit-learn, it supports
np.nan
values in the input and calculates the standard deviation of the predictions. Implemented in numba for speed - parallelization: A wrapper around joblib for its most common use case. Mainly included as a dependency of NWKR.
- utilities: Utility functions included as a dependency.
The code is published to help with reproducibility, and in support of the open source philosophy.
import numpy as np
from ectools.NWKR import NWKR
X = np.array([[1,1],[1,1]])
y = np.array([1,1])
model = NWKR()
model.fit(X,y)
prediction, prediction_std = model.predict(X)
print(prediction, prediction_std)
The code has been tested with python 3.6. Just pull the code with
git clone git@github.com:ganileni/ectools.git
and install the requirements:
cd ectools
pip install -r requirements.txt
if the tests work correctly:
cd tests/
nosetests
you're good to go.
You can install the package with
python setup.py install
or only symlink the files in your python installation with
python setup.py develop
Just me.
vanilla MIT license. Check out LICENSE.