Skip to main content

Python implementation of the Multilayer Credit Scoring algorithm from Óskarsdóttir & Bravo (2019)

Project description

mulp

This repository/package includes a python script that implements the Multilayer PageRank algorithm presented in Bravo and Óskarsdóttir (2020) and Óskarsdóttir and Bravo (2021, ArXiV , Publisher).

Installation

pip install mulp

Input instructions

There are three primary input files:

  • Individual layer files (.ncol)
  • Common Nodes file (csv)
  • Personal Node file (csv)

Each layer in the multilayer network requires its own .ncol file with the appropriate ncol file format.

Example ncol layer file (.ncol):

CommonNodeA SpecificNodeA
CommonNodeB SpecificNodeA
CommonNodeC SpecificNodeB
CommonNodeD SpecificNodeC

The inter-layer connections are only allowed between common nodes as to follow the structure layed out by Óskarsdóttir & Bravo (2021):

Example input file(.csv):

CommonNode1
CommonNode2
CommonNode3

To construct the personal matrix one must specify the influence (or personal) nodes in the following format (example input .csv file):

InfluentialNode1
InfluentialNode2
InfluentialNode3

Usage

Multilayer Network Initialization

To create a Multilayer Network the following arguments are available:

layer_files (list): list of layer files

common_nodes_file (str): csv file to common nodes

personal_file (str): file to create personal matrix

bidirectional (bool, optional): wheter edges are biderectional or not. Defaults to False.

sparse (bool, optional): use sparse or dense matrix. Defaults to True.

from mulp import MultiLayerRanker
ranker = MultiLayerRanker(layer_files=['products.ncol','districts.ncol'],
                           common_nodes_file= './common.csv',
                           personal_file= './personal.csv' ,
                           bidirectional=True,
                           sparse = True)

The test directory on the project Github includes some other examples for non-directional or non-sparse matrices.

Ranking

The rank method of the MultiLayerRanker class runs the MultiLayer Personalized PageRank Algorithm. One can choose to run different experiments with varying alphas by specifying it in the method call:

alpha (int,optional): PageRank exploration parameter, defaults to .85

eigs = ranker.pageRank(alpha = .85)

This method returns the leading eigenvector corresponding to each node's rank.

Output Formatting

The formattedRanks method allows getting the rankings with appropriate node labels in a dictionary format: x

eigs (ndarray): corresponding eigenvector to format

ranker.formattedRanks(eigs)

The adjDF method allows getting a personal or adjacency matrix with corresponding labels as a dataframe:

matrix (ndarray) : an adj matrix or personal matrix to transform

f (str,optional): Optional, if true, writes the df to an output csv

#for persoanl matrix
personalDF = ranker.toDf(ranker.personal)
#for adj matrix
adjDf = ranker.toDf(ranker.matrix)

mulp Average Daily Downloads

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

mulp-1.1.0.tar.gz (17.5 kB view details)

Uploaded Source

Built Distribution

mulp-1.1.0-py3-none-any.whl (17.8 kB view details)

Uploaded Python 3

File details

Details for the file mulp-1.1.0.tar.gz.

File metadata

  • Download URL: mulp-1.1.0.tar.gz
  • Upload date:
  • Size: 17.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.5

File hashes

Hashes for mulp-1.1.0.tar.gz
Algorithm Hash digest
SHA256 103e4cf491b4b7aaa30d6b228f81b6fed017692210ba85a450553cf5c1d38897
MD5 7acc0379042be7b6060841bd53b7ecb8
BLAKE2b-256 bbebd2fcab431bf4f1abf89cd101101d29ff400021d10805b4463d18594d3bb3

See more details on using hashes here.

File details

Details for the file mulp-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: mulp-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 17.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.5

File hashes

Hashes for mulp-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 af44194ef566fd57f007d1e0499f2164d72c90bd69cb6de551bffd9e4022687b
MD5 6850f41ecbdc98cedb2a798c22c99445
BLAKE2b-256 441032660411e406913731e5b064f1034b969dfd958e47dc7c57ddfbf4bd3e4e

See more details on using hashes here.

Supported by

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