logistic_regression.config module

Configuration parsing and storage for logistic regression

class logistic_regression.config.Config(clients, server, data_columns, target_column, intercept, n_epochs, learning_rate, hessian)[source]

Bases: object

The configuration of the experiment.

Parameters:
  • clients (list[Party]) – List of clients

  • server (Party) – Server party

  • data_columns (list[str]) – Names of data columns

  • target_column (str) – Name of target column

  • intercept (bool) – Whether to use intercept column

  • n_epochs (int) – Number of epochs

  • learning_rate (float | None) – Learning rate

  • hessian (bool) – Whether to use second derivative

clients: list[Party]
data_columns: list[str]
static from_file(config_path)[source]

Create config from config file.

Parameters:

config_path (Path) – The path to the file

Return type:

Config

Returns:

The configuration according to config file

get_client_by_name(client_name)[source]

Get a client by name.

Parameters:

client_name (str) – the name of the party which is requested

Return type:

Party

Returns:

the client with name client_name

Raises:

ValueError – if the client name is not in the list of clients

hessian: bool
intercept: bool
learning_rate: float | None
n_epochs: int
server: Party
target_column: str
class logistic_regression.config.ConfigParser(config_file_path)[source]

Bases: object

Parser for config file.

Parameters:
  • LIST_SEPARATOR – the separator used for lists in the config file.

  • EXPERIMENT_SECTION – The section name for experiment config.

  • EXPERIMENT_DATA_COLUMNS_KEY – Key for which columns of data file should be used in training data.

  • EXPERIMENT_TARGET_COLUMN_KEY – Key for which column contains target values.

  • EXPERIMENT_INTERCEPT_KEY – Key for value whether intercept is used.

  • EXPERIMENT_EPOCHS_KEY – Key for number of epochs

  • EXPERIMENT_LEARNING_RATE_KEY – Key for learning rate (number or hessian)

  • PARTY_SECTION – The section name for the parties section

  • SERVER_NAME_KEY – Key for name of the server

  • CLIENT_NAMES_KEY – Key for the list of client names

  • PARTY_ADDRESS_KEY – Key for the network address of party

  • PARTY_PORT_KEY – Key for network party of party

  • PARTY_TRAIN_DATA_KEY – Key for training data location for party

CLIENT_NAMES_KEY = 'clients'
EXPERIMENT_DATA_COLUMNS_KEY = 'data_columns'
EXPERIMENT_EPOCHS_KEY = 'n_epochs'
EXPERIMENT_INTERCEPT_KEY = 'intercept'
EXPERIMENT_LEARNING_RATE_KEY = 'learning_rate'
EXPERIMENT_SECTION = 'Experiment'
EXPERIMENT_TARGET_COLUMN_KEY = 'target_column'
LIST_SEPARATOR = ','
PARTY_ADDRESS_KEY = 'address'
PARTY_PORT_KEY = 'port'
PARTY_SECTION = 'Parties'
PARTY_TRAIN_DATA_KEY = 'train_data'
SERVER_NAME_KEY = 'server'
__init__(config_file_path)[source]

Load the config file and parse the objects variables from the file.

Parameters:

config_file_path (Path) – The path to the config file

load_config(config_file_path)[source]

Load the config file.

Parameters:

config_file_path (Path) – The path to the config file

Return type:

None

parse_clients()[source]

Parse the list of clients from the config.

Return type:

list[Party]

Returns:

the list of clients from the config file

parse_data_columns()[source]

Parse the data columns from config file.

Return type:

list[str]

Returns:

The list of data columns names

parse_intercept()[source]

Parse whether intercept column should be added according to config.

Return type:

bool

Returns:

Whether intercept column should be added

parse_learning_rate()[source]

Parse learning rate from config.

Return type:

tuple[float | None, bool]

Returns:

First element of tuple is a boolean indicating whether a hessian must be used. Second element is the learning rate if applicable.

Raises:

ValueError – if learning rate cannot be parsed.

parse_list(section, key)[source]

Parse a config item that contains a list of values.

Parameters:
  • section (str) – Which [Section] in the config you want

  • key (str) – Which key you want within that section

Return type:

list[str]

Returns:

List of values given for that key

parse_n_epochs()[source]

Parse number of epochs from config.

Return type:

int

Returns:

number of epochs

parse_party(name)[source]

Parse party with given name from config file.

Parameters:

name (str) – the name of the party to parse

Return type:

Party

Returns:

the list of clients from the config file

parse_server()[source]

Parse the server from the config.

Return type:

Party

Returns:

the server from the config file

parse_target_column()[source]

Parse the target column from config file.

Return type:

str

Returns:

The target column name

to_config()[source]

Convert the parse to an actual config object.

Return type:

Config

Returns:

the config object containing the data from the parsed config file

class logistic_regression.config.Party(name, address, port, train_data_path)[source]

Bases: object

Class representing a party. Contains the data required by the communication pool.

Parameters:
  • name (str) – The name of the party

  • address (str) – The network address of the party

  • port (int) – The network port of the party

  • train_data_path (Path) – The path to the training data

address: str
name: str
port: int
train_data_path: Path