federated/data/data_preprocessing.py
def create_class_distributed_dataset(
    X: np.ndarray, y: np.ndarray, number_of_clients: int
) -> Tuple[Dict, tff.simulation.ClientData]:
    """Function distributes the data in a way such that each client gets one type of data.

    Args:
        X (np.ndarray): Input.\n
        y (np.ndarray): Output.\n
        number_of_clients (int): Number of clients.\n
    Returns:
        [Dict, tff.simulation.ClientData]: A dictionary and a tensorflow federated dataset containing the distributed dataset.
    """
    n = len(X)
    clients_data = {f"client_{i}": [[], []] for i in range(1, 6)}

    for i in range(n):
        index = np.where(y[i] == 1)[0][0]
        clients_data[f"client_{index+1}"][0].append(X[i])
        clients_data[f"client_{index+1}"][1].append(y[i])

    return clients_data, create_tff_dataset(clients_data)
Function distributes the data in a way such that each client gets one type of data.

    Args:
        X (np.ndarray): Input.\n
        y (np.ndarray): Output.\n
        number_of_clients (int): Number of clients.\n
    Returns:
        [Dict, tff.simulation.ClientData]: A dictionary and a tensorflow federated dataset containing the distributed dataset.
    
Function distributes the data in a way such that each client gets one type of data.
Function distributes the data in a way such that each client gets one type of data .
def create_class_distributed_dataset(
    X: np.ndarray, y: np.ndarray, number_of_clients: int
) -> Tuple[Dict, tff.simulation.ClientData]:
    n = len(X)
    clients_data = {f"client_{i}": [[], []] for i in range(1, 6)}
    for i in range(n):
        index = np.where(y[i] == 1)[0][0]
        clients_data[f"client_{index+1}"][0].append(X[i])
        clients_data[f"client_{index+1}"][1].append(y[i])
    return clients_data, create_tff_dataset(clients_data)
def create_class_distributed_dataset ( X : np . ndarray , y : np . ndarray , number_of_clients : int ) -> Tuple [ Dict , tff . simulation . ClientData ] : n = len ( X ) clients_data = { f"client_{i}" : [ [ ] , [ ] ] for i in range ( 1 , 6 ) } for i in range ( n ) : index = np . where ( y [ i ] == 1 ) [ 0 ] [ 0 ] clients_data [ f"client_{index+1}" ] [ 0 ] . append ( X [ i ] ) clients_data [ f"client_{index+1}" ] [ 1 ] . append ( y [ i ] ) return clients_data , create_tff_dataset ( clients_data )
Function distributes the data in a way such that each client gets one type of data.
Function distributes the data in a way such that each client gets one type of data .
"""Function distributes the data in a way such that each client gets one type of data.

    Args:
        X (np.ndarray): Input.\n
        y (np.ndarray): Output.\n
        number_of_clients (int): Number of clients.\n
    Returns:
        [Dict, tff.simulation.ClientData]: A dictionary and a tensorflow federated dataset containing the distributed dataset.
    """
A dictionary and a tensorflow federated dataset containing the distributed dataset.
A dictionary and a tensorflow federated dataset containing the distributed dataset .
[Dict, tff.simulation.ClientData]
X
np.ndarray
None
y
np.ndarray
None
number_of_clients
int
Number of clients.\n
Number of clients . \ n