Skip to main content

The graph ensemble package contains a set of methods to build fitness based graph ensembles from marginal information.

Project description

https://travis-ci.com/LeonardoIalongo/graph-ensembles.svg?branch=master

Graph ensembles

The graph ensemble package contains a set of methods to build fitness based graph ensembles from marginal information. These methods can be used to build randomized ensembles preserving the marginal information provided.

Installation

Install using:

pip install graph_ensembles

Usage

Currently only the RandomGraph and StripeFitnessModel are fully implemented. An example of how it can be used is the following. For more see the example notebooks in the examples folder.

import graph_ensembles as ge
import pandas as pd

v = pd.DataFrame([['ING', 'NL'],
                 ['ABN', 'NL'],
                 ['BNP', 'FR'],
                 ['BNP', 'IT']],
                 columns=['name', 'country'])

e = pd.DataFrame([['ING', 'NL', 'ABN', 'NL', 1e6, 'interbank', False],
                 ['BNP', 'FR', 'ABN', 'NL', 2.3e7, 'external', False],
                 ['BNP', 'IT', 'ABN', 'NL', 7e5, 'interbank', True],
                 ['BNP', 'IT', 'ABN', 'NL', 3e3, 'interbank', False],
                 ['ABN', 'NL', 'BNP', 'FR', 1e4, 'interbank', False],
                 ['ABN', 'NL', 'ING', 'NL', 4e5, 'external', True]],
                 columns=['creditor', 'c_country',
                          'debtor', 'd_country',
                          'value', 'type', 'EUR'])

g = ge.Graph(v, e, v_id=['name', 'country'],
             src=['creditor', 'c_country'],
             dst=['debtor', 'd_country'],
             edge_label=['type', 'EUR'],
             weight='value')

# Initialize model
model = ge.StripeFitnessModel(g)

# Fit model parameters
model.fit()

# Sample from the ensemble
model.sample()

Development

Please work on a feature branch and create a pull request to the development branch. If necessary to merge manually do so without fast forward:

git merge --no-ff myfeature

To build a development environment run:

python3 -m venv env
source env/bin/activate
pip install -e '.[dev]'

For testing:

pytest --cov

Credits

This is a project by Leonardo Niccolò Ialongo and Emiliano Marchese, under the supervision of Diego Garlaschelli.

History

0.1.2 (2012-04-07)

  • Added scale invariant probability functional to all models

  • Improved methods for convergence with change in API, xtol now a relative measure

  • Added pagerank and trophic depth to the library

  • Added methods for graph conversion to networkx

  • Added methods for computing the adjacency matrix as a sparse matrix

0.1.1 (2021-03-29)

  • Fixed bug in stripe expected degree computation

  • Added testing of expected degree performance

0.1.0 (2021-03-29)

  • Added the block model and group info to graphs

  • Added fast implementation of theoretical expected degrees

  • Fixed some compatibility issues with multiple item assignments

0.0.4 (2021-03-15)

  • Fixed issues with slow pandas index conversion

0.0.3 (2021-03-14)

  • Large changes in API with great improvements in usability

  • Added sampling function

  • Added RandomGraph model

  • Added Graph classes for ease of use

0.0.2 (2020-11-13)

  • Added steps for CI.

  • Corrected broken links.

  • Removed support for python 3.5 and 3.6

0.0.1 (2020-10-28)

  • First release on PyPI. StripeFitnessModel available, all other model classes still dummies.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

graph-ensembles-0.1.2.tar.gz (170.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

graph_ensembles-0.1.2-py3-none-any.whl (26.4 kB view details)

Uploaded Python 3

File details

Details for the file graph-ensembles-0.1.2.tar.gz.

File metadata

  • Download URL: graph-ensembles-0.1.2.tar.gz
  • Upload date:
  • Size: 170.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.7.2 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.7

File hashes

Hashes for graph-ensembles-0.1.2.tar.gz
Algorithm Hash digest
SHA256 bffb957cf68562f4589593fcbcff55e1e4b04654126672eb5d4bec6b120adbbf
MD5 c49397dd68c8c180de0cdd53b2b8abe3
BLAKE2b-256 8dc83ec90cd3a9c0656ae24d320749986dae0ce053bbdfa965381d8cdcca7a72

See more details on using hashes here.

File details

Details for the file graph_ensembles-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: graph_ensembles-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 26.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.7.2 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.7

File hashes

Hashes for graph_ensembles-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 43b0c825e516f377d25354386a50bc2901297309c0372ea06c09bd19da23e41a
MD5 540731b5360e2611f7e00cdac89b9527
BLAKE2b-256 282a48dba82638973a1da2417f7c7a9470e7dc0788ae85a4924f9159f022e8a4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page