risk_propagation.bank module¶
Configuration of a bank
- class risk_propagation.bank.Bank(name, transactions=None)[source]¶
Bases:
object
Class containing the configuration of a single bank
- __init__(name, transactions=None)[source]¶
Initializes a bank instance
- Parameters:
name (
str
) – name of the banktransactions (
Optional
[DataFrame
]) – optional dataframe with transactions to process
- property accounts: Set[str]¶
The collection of account labels of this bank
- Returns:
set of account labels of this bank
- property accounts_dict: Accounts¶
The collection of accounts of this bank
- Returns:
the accounts of this bank
- encrypt(public_key)[source]¶
Encrypts risk scores of all accounts of this bank
- Parameters:
public_key (
Union
[DistributedPaillier
,Paillier
]) – the public key used in the encryption- Return type:
None
- property external_accounts: Set[str]¶
The collection of external accounts
- Returns:
set of external accounts of this bank
- get_imported_risk_scores(account_keys=None)[source]¶
Gets the imported accounts risk scores
- Parameters:
account_keys (
Optional
[Set
[str
]]) – the scores to retrieve- Return type:
Dict
[str
,PaillierCiphertext
]- Returns:
dict of risk scores
- get_risk_scores(account_keys=None)[source]¶
Gets the accounts risk scores
- Parameters:
account_keys (
Optional
[Set
[str
]]) – the scores to retrieve- Return type:
Dict
[str
,PaillierCiphertext
]- Returns:
dict of risk scores
- property name: str¶
The name of the bank
- Returns:
the name of the bank instance
- process_accounts(dataframe, delta=0.5)[source]¶
Initialises the accounts belonging to this bank
- Parameters:
dataframe (
DataFrame
) – dataframe containing the accounts with risk scoresdelta (
float
) – the delta to be used
- Return type:
None
- process_transactions(dataframe)[source]¶
Processes the transaction dataframe
- Parameters:
dataframe (
DataFrame
) – dataframe with the following columns; “id_source”, “id_destination”, “amount”, “bank_source”, “bank_destination”- Raises:
ValueError – raised when provided dataframe does not contain the correct columns
- Return type:
None
- property risk_scores: Dict[str, PaillierCiphertext]¶
A dictionary of risk scores per account of this bank
- Returns:
a dictionary of all risk scores of this bank