Skip to main content

Data augmentation

Functions to augment the user’s dataset with information from official sources.

gingado provides data augmentation functionalities that can help users to augment their datasets with a time series dimension. This can be done both on a stand-alone basis as the user incorporates new data on top of the original dataset, or as part of a scikit-learn Pipeline that also includes other steps like data transformation and model estimation.

Data augmentation with SDMX

The Statistical Data and Metadata eXchange (SDMX) is an ISO standard comprising:

  • technical standards

  • statistical guidelines, including cross-domain concepts and codelists

  • an IT architecture and tools

SDMX is sponsored by the Bank for International Settlements, European Central Bank, Eurostat, International Monetary Fund, Organisation for Economic Co-operation and Development, United Nations, and World Bank Group.

More information about the SDMX is available on its webpage.

gingado uses SDMX to augment user datasets through the transformer AugmentSDMX.

For example, the code below is a simple illustration of AugmentSDMX augmentation under two scenarios: without a variance threshold (ie, including all data regardless if they are constants) or with a relatively high variance threshold (such that no data is actually added).

In both cases, the object is using the default data flow, which is the daily series of monetary policy rates set by central banks.

These AugmentSDMX objects are used to augment a data frame with simulated data for illustrative purposes. In real life, this data would be the user’s original data.

rng = np.random.default_rng(seed=42)

periods = 15
idx = pd.date_range(freq='d', start='2020-01-01', periods=periods)
orig_data = pd.DataFrame({'orig_col': rng.standard_normal(periods)}, index=idx)
orig_data.head()
orig_col
2020-01-01 0.304717
2020-01-02 -1.039984
2020-01-03 0.750451
2020-01-04 0.940565
2020-01-05 -1.951035
from gingado.augmentation import AugmentSDMX
aug_NoVarThresh = AugmentSDMX(variance_threshold=None)
aug_data = aug_NoVarThresh.fit_transform(orig_data)
aug_data
Querying data from BIS's dataflow 'WS_CBPOL' - Central bank policy rates...
orig_col BIS__WS_CBPOL_D__AU BIS__WS_CBPOL_D__CA BIS__WS_CBPOL_D__CH BIS__WS_CBPOL_D__CL BIS__WS_CBPOL_D__CN BIS__WS_CBPOL_D__CO BIS__WS_CBPOL_D__CZ BIS__WS_CBPOL_D__DK BIS__WS_CBPOL_D__GB ... BIS__WS_CBPOL_D__RU BIS__WS_CBPOL_D__SA BIS__WS_CBPOL_D__SE BIS__WS_CBPOL_D__TH BIS__WS_CBPOL_D__TR BIS__WS_CBPOL_D__US BIS__WS_CBPOL_D__XM BIS__WS_CBPOL_D__ZA BIS__WS_CBPOL_D__AR BIS__WS_CBPOL_D__BR
2020-01-01 0.304717 NaN 1.75 -0.75 NaN 4.15 4.25 NaN NaN NaN ... NaN 2.25 NaN NaN NaN 1.625 0.0 NaN 55.0 4.5
2020-01-02 -1.039984 0.75 1.75 -0.75 1.75 4.15 4.25 2.0 -0.75 0.75 ... NaN 2.25 -0.25 1.25 12.0 1.625 0.0 6.5 55.0 4.5
2020-01-03 0.750451 0.75 1.75 -0.75 1.75 4.15 4.25 2.0 -0.75 0.75 ... NaN 2.25 -0.25 1.25 12.0 1.625 0.0 6.5 55.0 4.5
2020-01-04 0.940565 0.75 1.75 -0.75 1.75 4.15 4.25 2.0 -0.75 0.75 ... NaN 2.25 -0.25 1.25 12.0 1.625 0.0 6.5 55.0 4.5
2020-01-05 -1.951035 0.75 1.75 -0.75 1.75 4.15 4.25 2.0 -0.75 0.75 ... NaN 2.25 -0.25 1.25 12.0 1.625 0.0 6.5 55.0 4.5
2020-01-06 -1.302180 0.75 1.75 -0.75 1.75 4.15 4.25 2.0 -0.75 0.75 ... 6.25 2.25 -0.25 1.25 12.0 1.625 0.0 6.5 55.0 4.5
2020-01-07 0.127840 0.75 1.75 -0.75 1.75 4.15 4.25 2.0 -0.75 0.75 ... 6.25 2.25 -0.25 1.25 12.0 1.625 0.0 6.5 55.0 4.5
2020-01-08 -0.316243 0.75 1.75 -0.75 1.75 4.15 4.25 2.0 -0.75 0.75 ... 6.25 2.25 0.00 1.25 12.0 1.625 0.0 6.5 55.0 4.5
2020-01-09 -0.016801 0.75 1.75 -0.75 1.75 4.15 4.25 2.0 -0.75 0.75 ... 6.25 2.25 0.00 1.25 12.0 1.625 0.0 6.5 55.0 4.5
2020-01-10 -0.853044 0.75 1.75 -0.75 1.75 4.15 4.25 2.0 -0.75 0.75 ... 6.25 2.25 0.00 1.25 12.0 1.625 0.0 6.5 52.0 4.5
2020-01-11 0.879398 0.75 1.75 -0.75 1.75 4.15 4.25 2.0 -0.75 0.75 ... 6.25 2.25 0.00 1.25 12.0 1.625 0.0 6.5 52.0 4.5
2020-01-12 0.777792 0.75 1.75 -0.75 1.75 4.15 4.25 2.0 -0.75 0.75 ... 6.25 2.25 0.00 1.25 12.0 1.625 0.0 6.5 52.0 4.5
2020-01-13 0.066031 0.75 1.75 -0.75 1.75 4.15 4.25 2.0 -0.75 0.75 ... 6.25 2.25 0.00 1.25 12.0 1.625 0.0 6.5 52.0 4.5
2020-01-14 1.127241 0.75 1.75 -0.75 1.75 4.15 4.25 2.0 -0.75 0.75 ... 6.25 2.25 0.00 1.25 12.0 1.625 0.0 6.5 52.0 4.5
2020-01-15 0.467509 0.75 1.75 -0.75 1.75 4.15 4.25 2.0 -0.75 0.75 ... 6.25 2.25 0.00 1.25 12.0 1.625 0.0 6.5 52.0 4.5

15 rows × 40 columns

aug_StrictVarThresh = AugmentSDMX(variance_threshold=10)
aug_data = aug_StrictVarThresh.fit_transform(orig_data)
aug_data
Querying data from BIS's dataflow 'WS_CBPOL' - Central bank policy rates...
No columns added to original data because no feature in x meets the variance threshold 10.00000
orig_col
2020-01-01 0.304717
2020-01-02 -1.039984
2020-01-03 0.750451
2020-01-04 0.940565
2020-01-05 -1.951035
2020-01-06 -1.302180
2020-01-07 0.127840
2020-01-08 -0.316243
2020-01-09 -0.016801
2020-01-10 -0.853044
2020-01-11 0.879398
2020-01-12 0.777792
2020-01-13 0.066031
2020-01-14 1.127241
2020-01-15 0.467509

AugmentSDMX

AugmentSDMX (sources: 'dict' = {'BIS': 'WS_CBPOL'}, variance_threshold: 'float | None' = None, propagate_last_known_value: 'bool' = True, fillna: 'float | int' = 0, verbose: 'bool' = True)

A transformer that augments a dataset using SDMX data.

Attributes:
    sources (dict): A dictionary with sources as keys and dataflows as values.
    variance_threshold (float | None): Variables with lower variance through time are removed if specified. Otherwise, all variables are kept.
    propagate_last_known_value (bool): Whether to propagate the last known non-NA value to following dates.
    fillna (float | int): Value to use to fill missing data.
    verbose (bool): Whether to inform the user about the process progress.

fit

fit (self, X: 'pd.Series | pd.DataFrame', y: 'None' = None)

Fits the instance of AugmentSDMX to `X`, learning its time series frequency.

Args:
    X (pd.Series | pd.DataFrame): Data having an index of `datetime` type.
    y (None): `y` is kept as an argument for API consistency only.

Returns:
    AugmentSDMX: A fitted version of the same AugmentSDMX instance.

transform

transform (self, X: 'pd.Series | pd.DataFrame', y: 'None' = None, training: 'bool' = False) -> 'np.ndarray'

Transforms input dataset `X` by adding the requested data using SDMX.

Args:
    X (pd.Series | pd.DataFrame): Data having an index of `datetime` type.
    y (None): `y` is kept as an argument for API consistency only.
    training (bool): `True` if `transform` is called during training, `False` (default) if called during testing.

Returns:
    np.ndarray: `X` augmented with data from SDMX with the same number of samples but more columns.

fit_transform

fit_transform (self, X: 'pd.Series | pd.DataFrame', y: 'None' = None) -> 'np.ndarray'

Fit to data, then transform it.

Args:
    X (pd.Series | pd.DataFrame): Data having an index of `datetime` type.
    y (None): `y` is kept as an argument for API consistency only.

Returns:
    np.ndarray: `X` augmented with data from SDMX with the same number of samples but more columns.

Compatibility with scikit-learn

As mentioned above, gingado’s transformers are built to be compatible with scikit-learn. The code below demonstrates this compatibility.

First, we create the example dataset. In this case, it comprises the daily foreign exchange rate of selected currencies to the Euro. The Brazilian Real (BRL) is chosen for this example as the dependent variable.

from gingado.utils import load_SDMX_data, Lag
from sklearn.model_selection import TimeSeriesSplit
X = load_SDMX_data(
    sources={'ECB': 'EXR'}, 
    keys={'FREQ': 'D', 'CURRENCY': ['EUR', 'AUD', 'BRL', 'CAD', 'CHF', 'GBP', 'JPY', 'SGD', 'USD']},
    params={"startPeriod": 2003}
    )
# drop rows with empty values
X.dropna(inplace=True)
# adjust column names in this simple example for ease of understanding:
# remove parts related to source and dataflow names
X.columns = X.columns.str.replace("ECB__EXR_D__", "").str.replace("__EUR__SP00__A", "")
X = Lag(lags=1, jump=0, keep_contemporaneous_X=True).fit_transform(X)
y = X.pop('BRL')
# retain only the lagged variables in the X variable
X = X[X.columns[X.columns.str.contains('_lag_')]]
Querying data from ECB's dataflow 'EXR' - Exchange Rates...
X_train, X_test = X.iloc[:-1], X.tail(1)
y_train, y_test = y.iloc[:-1], y.tail(1)

X_train.shape, y_train.shape, X_test.shape, y_test.shape
((6113, 8), (6113,), (1, 8), (1,))

Next, the data augmentation object provided by gingado adds more data. In this case, for brevity only one dataflow from one source is listed. If users want to add more SDMX sources, simply add more keys to the dictionary. And if users want data from all dataflows from a given source provided the keys and parameters such as frequency and dates match, the value should be set to 'all', as in {'ECB': ['CISS'], 'BIS': 'all'}.

test_src = {'ECB': ['CISS'], 'BIS': ['WS_CBPOL']}

X_train__fit_transform = AugmentSDMX(sources=test_src).fit_transform(X=X_train)
X_train__fit_then_transform = AugmentSDMX(sources=test_src).fit(X=X_train).transform(X=X_train, training=True)

assert X_train__fit_transform.shape == X_train__fit_then_transform.shape
Querying data from ECB's dataflow 'CISS' - Composite Indicator of Systemic Stress...
Querying data from BIS's dataflow 'WS_CBPOL' - Central bank policy rates...
Querying data from ECB's dataflow 'CISS' - Composite Indicator of Systemic Stress...
Querying data from BIS's dataflow 'WS_CBPOL' - Central bank policy rates...

This is the dataset now after this particular augmentation:

print(f"No of columns: {len(X_train__fit_transform.columns)} {X_train__fit_transform.columns}")
X_train__fit_transform
No of columns: 89 Index(['AUD_lag_1', 'BRL_lag_1', 'CAD_lag_1', 'CHF_lag_1', 'GBP_lag_1',
       'JPY_lag_1', 'SGD_lag_1', 'USD_lag_1',
       'ECB__CISS_D__AT__Z0Z__4F__EC__SOV_CIN__IDX',
       'ECB__CISS_D__AT__Z0Z__4F__EC__SS_CIN__IDX',
       'ECB__CISS_D__BE__Z0Z__4F__EC__SOV_CIN__IDX',
       'ECB__CISS_D__BE__Z0Z__4F__EC__SS_CIN__IDX',
       'ECB__CISS_D__CN__Z0Z__4F__EC__SS_CIN__IDX',
       'ECB__CISS_D__DE__Z0Z__4F__EC__SOV_CIN__IDX',
       'ECB__CISS_D__DE__Z0Z__4F__EC__SS_CIN__IDX',
       'ECB__CISS_D__ES__Z0Z__4F__EC__SOV_CIN__IDX',
       'ECB__CISS_D__ES__Z0Z__4F__EC__SS_CIN__IDX',
       'ECB__CISS_D__FI__Z0Z__4F__EC__SOV_CIN__IDX',
       'ECB__CISS_D__FI__Z0Z__4F__EC__SS_CIN__IDX',
       'ECB__CISS_D__FR__Z0Z__4F__EC__SOV_CIN__IDX',
       'ECB__CISS_D__FR__Z0Z__4F__EC__SS_CIN__IDX',
       'ECB__CISS_D__GB__Z0Z__4F__EC__SS_CIN__IDX',
       'ECB__CISS_D__GR__Z0Z__4F__EC__SOV_CIN__IDX',
       'ECB__CISS_D__IE__Z0Z__4F__EC__SOV_CIN__IDX',
       'ECB__CISS_D__IE__Z0Z__4F__EC__SS_CIN__IDX',
       'ECB__CISS_D__IT__Z0Z__4F__EC__SOV_CIN__IDX',
       'ECB__CISS_D__IT__Z0Z__4F__EC__SS_CIN__IDX',
       'ECB__CISS_D__NL__Z0Z__4F__EC__SOV_CIN__IDX',
       'ECB__CISS_D__NL__Z0Z__4F__EC__SS_CIN__IDX',
       'ECB__CISS_D__PT__Z0Z__4F__EC__SOV_CIN__IDX',
       'ECB__CISS_D__PT__Z0Z__4F__EC__SS_CIN__IDX',
       'ECB__CISS_D__U2__Z0Z__4F__EC__SOV_EWN__IDX',
       'ECB__CISS_D__U2__Z0Z__4F__EC__SOV_GDPWN__IDX',
       'ECB__CISS_D__U2__Z0Z__4F__EC__SS_BM__CON',
       'ECB__CISS_D__U2__Z0Z__4F__EC__SS_BMN__CON',
       'ECB__CISS_D__U2__Z0Z__4F__EC__SS_CI__IDX',
       'ECB__CISS_D__U2__Z0Z__4F__EC__SS_CIN__IDX',
       'ECB__CISS_D__U2__Z0Z__4F__EC__SS_CO__CON',
       'ECB__CISS_D__U2__Z0Z__4F__EC__SS_CON__CON',
       'ECB__CISS_D__U2__Z0Z__4F__EC__SS_EM__CON',
       'ECB__CISS_D__U2__Z0Z__4F__EC__SS_EMN__CON',
       'ECB__CISS_D__U2__Z0Z__4F__EC__SS_FI__CON',
       'ECB__CISS_D__U2__Z0Z__4F__EC__SS_FIN__CON',
       'ECB__CISS_D__U2__Z0Z__4F__EC__SS_FX__CON',
       'ECB__CISS_D__U2__Z0Z__4F__EC__SS_FXN__CON',
       'ECB__CISS_D__U2__Z0Z__4F__EC__SS_MM__CON',
       'ECB__CISS_D__U2__Z0Z__4F__EC__SS_MMN__CON',
       'ECB__CISS_D__US__Z0Z__4F__EC__SS_CI__IDX',
       'ECB__CISS_D__US__Z0Z__4F__EC__SS_CIN__IDX', 'BIS__WS_CBPOL_D__AU',
       'BIS__WS_CBPOL_D__CA', 'BIS__WS_CBPOL_D__CH', 'BIS__WS_CBPOL_D__CL',
       'BIS__WS_CBPOL_D__CN', 'BIS__WS_CBPOL_D__CO', 'BIS__WS_CBPOL_D__CZ',
       'BIS__WS_CBPOL_D__DK', 'BIS__WS_CBPOL_D__GB', 'BIS__WS_CBPOL_D__HK',
       'BIS__WS_CBPOL_D__HR', 'BIS__WS_CBPOL_D__HU', 'BIS__WS_CBPOL_D__ID',
       'BIS__WS_CBPOL_D__IL', 'BIS__WS_CBPOL_D__IN', 'BIS__WS_CBPOL_D__IS',
       'BIS__WS_CBPOL_D__JP', 'BIS__WS_CBPOL_D__KR', 'BIS__WS_CBPOL_D__KW',
       'BIS__WS_CBPOL_D__MA', 'BIS__WS_CBPOL_D__MK', 'BIS__WS_CBPOL_D__MX',
       'BIS__WS_CBPOL_D__MY', 'BIS__WS_CBPOL_D__NO', 'BIS__WS_CBPOL_D__NZ',
       'BIS__WS_CBPOL_D__PE', 'BIS__WS_CBPOL_D__PH', 'BIS__WS_CBPOL_D__PL',
       'BIS__WS_CBPOL_D__RO', 'BIS__WS_CBPOL_D__RS', 'BIS__WS_CBPOL_D__RU',
       'BIS__WS_CBPOL_D__SA', 'BIS__WS_CBPOL_D__SE', 'BIS__WS_CBPOL_D__TH',
       'BIS__WS_CBPOL_D__TR', 'BIS__WS_CBPOL_D__US', 'BIS__WS_CBPOL_D__XM',
       'BIS__WS_CBPOL_D__ZA', 'BIS__WS_CBPOL_D__AR', 'BIS__WS_CBPOL_D__BR'],
      dtype='object')
AUD_lag_1 BRL_lag_1 CAD_lag_1 CHF_lag_1 GBP_lag_1 JPY_lag_1 SGD_lag_1 USD_lag_1 ECB__CISS_D__AT__Z0Z__4F__EC__SOV_CIN__IDX ECB__CISS_D__AT__Z0Z__4F__EC__SS_CIN__IDX ... BIS__WS_CBPOL_D__RU BIS__WS_CBPOL_D__SA BIS__WS_CBPOL_D__SE BIS__WS_CBPOL_D__TH BIS__WS_CBPOL_D__TR BIS__WS_CBPOL_D__US BIS__WS_CBPOL_D__XM BIS__WS_CBPOL_D__ZA BIS__WS_CBPOL_D__AR BIS__WS_CBPOL_D__BR
TIME_PERIOD
2003-01-03 1.8554 3.6770 1.6422 1.4528 0.65200 124.40 1.8188 1.0446 0.071990 0.021899 ... NaN NaN 3.75 1.75 44.0 1.250 2.75 13.50 6.05 25.00
2003-01-06 1.8440 3.6112 1.6264 1.4555 0.65000 124.56 1.8132 1.0392 0.060339 0.020801 ... NaN 2.0 3.75 1.75 44.0 1.250 2.75 13.50 5.95 25.00
2003-01-07 1.8281 3.5145 1.6383 1.4563 0.64950 124.40 1.8210 1.0488 0.048149 0.019738 ... NaN 2.0 3.75 1.75 44.0 1.250 2.75 13.50 6.14 25.00
2003-01-08 1.8160 3.5139 1.6257 1.4565 0.64960 124.82 1.8155 1.0425 0.046481 0.019947 ... 21.0 2.0 3.75 1.75 44.0 1.250 2.75 13.50 6.04 25.00
2003-01-09 1.8132 3.4405 1.6231 1.4586 0.64950 124.90 1.8102 1.0377 0.032815 0.017026 ... 21.0 2.0 3.75 1.75 44.0 1.250 2.75 13.50 5.70 25.00
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
2026-11-10 1.6236 6.1748 1.5785 0.9164 0.83430 176.79 1.4328 1.1193 0.053411 0.004666 ... 14.0 4.5 1.75 1.00 36.0 3.875 2.50 7.25 29.00 13.75
2026-11-11 1.6244 6.2257 1.5852 0.9203 0.83545 177.38 1.4335 1.1214 0.053311 0.004776 ... 14.0 4.5 1.75 1.00 36.0 3.875 2.50 7.25 29.00 13.75
2026-11-12 1.6222 6.1827 1.5839 0.9234 0.83618 177.18 1.4271 1.1127 0.044076 0.004394 ... 14.0 4.5 1.75 1.00 36.0 3.875 2.50 7.25 29.00 13.75
2026-11-13 1.6246 6.2241 1.5789 0.9232 0.83595 176.96 1.4249 1.1081 0.025570 0.004173 ... 14.0 4.5 1.75 1.00 36.0 3.875 2.50 7.25 29.00 13.75
2026-11-16 1.6288 6.2595 1.5758 0.9266 0.83559 176.83 1.4236 1.1052 0.044644 0.004760 ... 14.0 4.5 1.75 1.00 36.0 3.875 2.50 7.25 29.00 13.75

6113 rows × 89 columns

Pipeline

AugmentSDMX can also be part of a Pipeline object, which minimises operational errors during modelling and avoids using testing data during training:

from sklearn.pipeline import Pipeline
from sklearn.experimental import enable_iterative_imputer
from sklearn.impute import IterativeImputer
from sklearn.ensemble import RandomForestRegressor
from sklearn.model_selection import GridSearchCV
pipeline = Pipeline([
    ('augmentation', AugmentSDMX(sources={'BIS': 'WS_CBPOL'})),
    ('imp', IterativeImputer(max_iter=10)),
    ('forest', RandomForestRegressor())
], verbose=True)

Tuning the data augmentation to enhance model performance

And since AugmentSDMX can be included in a Pipeline, it can also be fine-tuned by parameter search techniques (such as grid search), further helping users make the best of available data to enhance performance of their models.

Tip

Users can cache the data augmentation step to avoid repeating potentially lengthy data downloads. See the memory argument in the sklearn.pipeline.Pipeline documentation.

grid = GridSearchCV(
    estimator=pipeline,
    param_grid={
        'augmentation': ['passthrough', AugmentSDMX(sources={'ECB': 'CISS'})]
    },
    verbose=2,
    cv=TimeSeriesSplit(n_splits=2)
    )

y_pred_grid = grid.fit(X_train, y_train).predict(X_test)
Fitting 2 folds for each of 2 candidates, totalling 4 fits
[Pipeline] ...... (step 1 of 3) Processing augmentation, total=   0.0s
[Pipeline] ............... (step 2 of 3) Processing imp, total=   0.0s
[Pipeline] ............ (step 3 of 3) Processing forest, total=   0.6s
[CV] END ...........................augmentation=passthrough; total time=   0.6s
[Pipeline] ...... (step 1 of 3) Processing augmentation, total=   0.0s
[Pipeline] ............... (step 2 of 3) Processing imp, total=   0.0s
[Pipeline] ............ (step 3 of 3) Processing forest, total=   1.2s
[CV] END ...........................augmentation=passthrough; total time=   1.2s
Querying data from ECB's dataflow 'CISS' - Composite Indicator of Systemic Stress...
[Pipeline] ...... (step 1 of 3) Processing augmentation, total=   8.8s
[Pipeline] ............... (step 2 of 3) Processing imp, total=   0.2s
[Pipeline] ............ (step 3 of 3) Processing forest, total=   2.7s
Querying data from ECB's dataflow 'CISS' - Composite Indicator of Systemic Stress...
[CV] END ..augmentation=AugmentSDMX(sources={'ECB': 'CISS'}); total time=  23.8s
Querying data from ECB's dataflow 'CISS' - Composite Indicator of Systemic Stress...
[Pipeline] ...... (step 1 of 3) Processing augmentation, total=  15.4s
[Pipeline] ............... (step 2 of 3) Processing imp, total=   0.4s
[Pipeline] ............ (step 3 of 3) Processing forest, total=   6.0s
Querying data from ECB's dataflow 'CISS' - Composite Indicator of Systemic Stress...
[CV] END ..augmentation=AugmentSDMX(sources={'ECB': 'CISS'}); total time=  35.5s
[Pipeline] ...... (step 1 of 3) Processing augmentation, total=   0.0s
[Pipeline] ............... (step 2 of 3) Processing imp, total=   0.0s
[Pipeline] ............ (step 3 of 3) Processing forest, total=   1.8s
grid.best_params_
{'augmentation': 'passthrough'}
print(f"In this particular case, the best model was achieved by {'not ' if grid.best_params_['augmentation'] == 'passthrough' else ''}using the data augmentation.")
In this particular case, the best model was achieved by not using the data augmentation.
print(f"The last value in the training dataset was {y_train.tail(1).to_numpy()}. The predicted value was {y_pred_grid}, and the actual value was {y_test.to_numpy()}.")
The last value in the training dataset was [6.2838]. The predicted value was [6.283376], and the actual value was [6.3539].

Sources of data

gingado seeks to only lists realiable data sources by choice, with a focus on official sources. This is meant to provide users with the trust that their dataset will be complemented by reliable sources. Unfortunately, it is not possible at this stage to include all official sources given the substantial manual and maintenance work. gingado leverages the existence of the Statistical Data and Metadata eXchange (SDMX), an organisation of official data sources that establishes common data and metadata formats, to download data that is relevant (and hopefully also useful) to users.

The function list_SDMX_sources returns a list of codes corresponding to the data sources available to provide gingado users with data through SDMX.

from gingado.utils import list_SDMX_sources
list_SDMX_sources()
['ABS',
 'ABS_JSON',
 'AR1',
 'BBK',
 'BIS',
 'COMP',
 'ECB',
 'EMPL',
 'ESTAT',
 'ESTAT3',
 'ESTAT_COMEXT',
 'GROW',
 'ILO',
 'IMF',
 'IMF_DATA',
 'IMF_DATA3',
 'INEGI',
 'INSEE',
 'ISTAT',
 'LSD',
 'NB',
 'NBB',
 'OECD',
 'OECD3',
 'OECD_JSON',
 'SGR',
 'SGR3',
 'SPC',
 'STAT_EE',
 'StatCan',
 'UNESCO',
 'UNICEF',
 'UNSD',
 'UY110',
 'WB',
 'WB_WDI']

You can also see what the available dataflows are. The code below returns a dictionary where each key is the code for an SDMX source, and the values associated with each key are the code and name for the respective dataflows.

from gingado.utils import list_all_dataflows
dflows = list_all_dataflows()
dflows
BIS   BIS_REL_CAL                                   BIS_RELEASE_CALENDAR
      WS_CBPOL                                 Central bank policy rates
      WS_CBS_PUB                                    Consolidated banking
      WS_CBTA                                  Central bank total assets
      WS_CPMI_CASHLESS                            CPMI cashless payments
                                                      ...               
UNSD  DF_UNData_UNFCC                                    SDMX_GHG_UNDATA
WB    DF_WITS_Tariff_TRAINS             WITS - UNCTAD TRAINS Tariff Data
      DF_WITS_TradeStats_Development          WITS TradeStats Devlopment
      DF_WITS_TradeStats_Tariff                   WITS TradeStats Tariff
      DF_WITS_TradeStats_Trade                     WITS TradeStats Trade
Name: dataflow, Length: 21528, dtype: object

For example, the dataflows from the BIS are:

dflows['BIS']
BIS_REL_CAL                                 BIS_RELEASE_CALENDAR
WS_CBPOL                               Central bank policy rates
WS_CBS_PUB                                  Consolidated banking
WS_CBTA                                Central bank total assets
WS_CPMI_CASHLESS                          CPMI cashless payments
WS_CPMI_CT1                       CPMI comparative tables type 1
WS_CPMI_CT2                       CPMI comparative tables type 2
WS_CPMI_DEVICES                             CPMI payment devices
WS_CPMI_INSTITUT                               CPMI institutions
WS_CPMI_MACRO                                         CPMI macro
WS_CPMI_PARTICIP                               CPMI participants
WS_CPMI_SYSTEMS                                     CPMI systems
WS_CPP                                Commercial property prices
WS_CREDIT_GAP                                 Credit-to-GDP gaps
WS_DEBT_SEC2_PUB    International debt securities (BIS-compiled)
WS_DER_OTC_TOV                          OTC derivatives turnover
WS_DPP                      Detailed residential property prices
WS_DSR                                       Debt service ratios
WS_EER                                  Effective exchange rates
WS_GLI                               Global liquidity indicators
WS_LBS_D_PUB                                  Locational banking
WS_LONG_CPI                           Consumer prices statistics
WS_NA_SEC_C3                      BIS debt securities statistics
WS_NA_SEC_DSS                         Debt securities statistics
WS_OTC_DERIV2                        OTC derivatives outstanding
WS_SPP                      Selected residential property prices
WS_TC                                               Total credit
WS_XRU                                  US dollar exchange rates
WS_XTD_DERIV                         Exchange-traded derivatives
Name: dataflow, dtype: object