federated/data/data_preprocessing.py
def create_dataset(
    X: np.ndarray, y: np.ndarray, number_of_clients: int
) -> Tuple[None, tff.simulation.ClientData]:
    """Function converts pandas dataframe to tensorflow federated dataset.

    Args:
        X (np.ndarray): Inputs.\n
        y (np.ndarray): Outputs.\n
        number_of_clients (int): The number of clients to split the data between.\n

    Returns:
        [None, tff.simulation.ClientData]: Returns federated data distribution.
    """
    num_of_clients = NUM_OF_CLIENTS
    total_ecg_count = len(X)
    ecgs_per_set = int(np.floor(total_ecg_count / num_of_clients))

    client_dataset = collections.OrderedDict()
    for i in range(1, num_of_clients + 1):
        name_of_client = f"client_{i}"
        start = ecgs_per_set * (i - 1)
        end = ecgs_per_set * i
        data = collections.OrderedDict(
            (
                ("label", np.array(y[start:end], dtype=np.int32)),
                ("datapoints", np.array(X[start:end], dtype=np.float32)),
            )
        )
        client_dataset[name_of_client] = data

    return None, tff.simulation.FromTensorSlicesClientData(client_dataset)
Function converts pandas dataframe to tensorflow federated dataset.

    Args:
        X (np.ndarray): Inputs.\n
        y (np.ndarray): Outputs.\n
        number_of_clients (int): The number of clients to split the data between.\n

    Returns:
        [None, tff.simulation.ClientData]: Returns federated data distribution.
    
Function converts pandas dataframe to tensorflow federated dataset.
Function converts pandas dataframe to tensorflow federated dataset .
def create_dataset(
    X: np.ndarray, y: np.ndarray, number_of_clients: int
) -> Tuple[None, tff.simulation.ClientData]:
    num_of_clients = NUM_OF_CLIENTS
    total_ecg_count = len(X)
    ecgs_per_set = int(np.floor(total_ecg_count / num_of_clients))
    client_dataset = collections.OrderedDict()
    for i in range(1, num_of_clients + 1):
        name_of_client = f"client_{i}"
        start = ecgs_per_set * (i - 1)
        end = ecgs_per_set * i
        data = collections.OrderedDict(
            (
                ("label", np.array(y[start:end], dtype=np.int32)),
                ("datapoints", np.array(X[start:end], dtype=np.float32)),
            )
        )
        client_dataset[name_of_client] = data
    return None, tff.simulation.FromTensorSlicesClientData(client_dataset)
def create_dataset ( X : np . ndarray , y : np . ndarray , number_of_clients : int ) -> Tuple [ None , tff . simulation . ClientData ] : num_of_clients = NUM_OF_CLIENTS total_ecg_count = len ( X ) ecgs_per_set = int ( np . floor ( total_ecg_count / num_of_clients ) ) client_dataset = collections . OrderedDict ( ) for i in range ( 1 , num_of_clients + 1 ) : name_of_client = f"client_{i}" start = ecgs_per_set * ( i - 1 ) end = ecgs_per_set * i data = collections . OrderedDict ( ( ( "label" , np . array ( y [ start : end ] , dtype = np . int32 ) ) , ( "datapoints" , np . array ( X [ start : end ] , dtype = np . float32 ) ) , ) ) client_dataset [ name_of_client ] = data return None , tff . simulation . FromTensorSlicesClientData ( client_dataset )
Function converts pandas dataframe to tensorflow federated dataset.
Function converts pandas dataframe to tensorflow federated dataset .
"""Function converts pandas dataframe to tensorflow federated dataset.

    Args:
        X (np.ndarray): Inputs.\n
        y (np.ndarray): Outputs.\n
        number_of_clients (int): The number of clients to split the data between.\n

    Returns:
        [None, tff.simulation.ClientData]: Returns federated data distribution.
    """
Returns federated data distribution.
Returns federated data distribution .
[None, tff.simulation.ClientData]
X
np.ndarray
None
y
np.ndarray
None
number_of_clients
int
The number of clients to split the data between.\n
The number of clients to split the data between . \ n