logistic_regression.client module

Logistic regression client

class logistic_regression.client.Client(config, client_name)[source]

Bases: object

The client class, representing data owning clients in the learning process.

Parameters:

SERVER_ID – The name for the server

SERVER_ID = 'Server'
__init__(config, client_name)[source]

Initializes the client based on experiment config and the running client. This includes setting up communication channels and parsing the client data.

Parameters:
  • config (Config) – The experiment configuration.

  • client_name (str) – The name of client running the application.

compute_gradient(coefs)[source]

Compute the first-order gradient of the coefficients on the data.

Parameters:

coefs (ndarray[Any, dtype[float64]]) – The coefficients at which to compute the gradient.

Return type:

ndarray[Any, dtype[float64]]

Returns:

The gradient vector.

compute_hessian(coefs)[source]

Compute the second-order derivative of the coefficients on the data.

Parameters:

coefs (ndarray[Any, dtype[float64]]) – The coefficients at which to compute the gradient.

Return type:

ndarray[Any, dtype[float64]]

Returns:

The hessian matrix.

create_communication_pool()[source]

Create the communication pool with the client and the server.

Return type:

Pool

Returns:

The communication pool

initial_model()[source]

Computes the initial local model.

Return type:

ndarray[Any, dtype[float64]]

Returns:

The initial local model.

load_data()[source]

Parse the data from the input data file and split in train data and target values.

Return type:

tuple[ndarray[Any, dtype[float64]], ndarray[Any, dtype[bool_]]]

Returns:

A tuple containing a matrix of training data and a vector of target values.

Raises:

FileNotFoundError – if the data file does not exist.

async preprocessing()[source]

Perform preprocessing on the data. Adds an intercept column if needed according to config.

Return type:

None

async run()[source]

Perform the learning process.

Return type:

ndarray[Any, dtype[float64]]

Returns:

The resulting model.

async send_weight_to_server()[source]

Send the weights (number of rows) to the server.

Return type:

None