Skip to main content

FedArtML

Federated Learning for Artificial Intelligence and Machine Learning (FedArtML) is a Python-based software library publicly available on Pypi. The library aims to facilitate Federated Learning (FL) research and simplify the comparison between centralized Machine Learning and FL research results since it allows centralized datasets' partition in a systematic and controlled way regarding label, feature and quantity skewness. In addition, the library includes existing techniques for generating federated datasets in the relevant state-of-the-art and some other proposed by the authors. Moreover, it contains various metrics for quantifying the degree of non-IID (non-IID-ness) data residing across entities participating in decentralized data.

In this repository, you can find the library's source code, the installation command, some getting-started examples (including Jupyter Notebooks), and documentation regarding its use.

Enjoy it!

Installation


pip install fedartml

Get started

The following are examples to start using FedArtML to partition centralized data into Federated one considering label, feature and quantity skewness. You can also check broader guides to use this tool on the examples folder.

Label skew

Plotting an interactive stacked bar plot (with sliders) per each local node (client) and label's classes using the Dirichlet method.

from fedartml import InteractivePlots

from keras.datasets import cifar10



# Load CIFAR 10data

(x_train, y_train), (x_test, y_test) = cifar10.load_data()



# Define (centralized) labels to use 

CIFAR10_labels = y_train



# Instanciate InteractivePlots object

my_plot = InteractivePlots(labels = CIFAR10_labels)



# Show plot

my_plot.show_stacked_distr_dirichlet()

Creating federated data from centralized data using the Dirichlet method.

from fedartml import SplitAsFederatedData

from keras.datasets import cifar10

import numpy as np



# Define random state for reproducibility

random_state = 0



# Load data

(x_train_glob, y_train_glob), (x_test_glob, y_test_glob) = cifar10.load_data()

y_train_glob = np.reshape(y_train_glob, (y_train_glob.shape[0],))

y_test_glob = np.reshape(y_test_glob, (y_test_glob.shape[0],))



# Normalize pixel values to be between 0 and 1

x_train_glob, x_test_glob = x_train_glob / 255.0, x_test_glob / 255.0



# Instantiate a SplitAsFederatedData object

my_federater = SplitAsFederatedData(random_state = random_state)



# Get federated dataset from centralized dataset

clients_glob_dic, list_ids_sampled_dic, miss_class_per_node, distances = my_federater.create_clients(image_list = x_train_glob, label_list = y_train_glob, 

                                                             num_clients = 2, prefix_cli='Local_node', method = "dirichlet", alpha = 1)

Feature skew

Creating federated data from centralized data using the Hist-Dirichlet-based method.

from fedartml import SplitAsFederatedData

from keras.datasets import cifar10

import numpy as np



# Define random state for reproducibility

random_state = 0



# Load data

(x_train_glob, y_train_glob), (x_test_glob, y_test_glob) = cifar10.load_data()

y_train_glob = np.reshape(y_train_glob, (y_train_glob.shape[0],))

y_test_glob = np.reshape(y_test_glob, (y_test_glob.shape[0],))



# Normalize pixel values to be between 0 and 1

x_train_glob, x_test_glob = x_train_glob / 255.0, x_test_glob / 255.0



# Instantiate a SplitAsFederatedData object

my_federater = SplitAsFederatedData(random_state = random_state)



# Get federated dataset from centralized dataset

clients_glob_dic, list_ids_sampled_dic, miss_class_per_node, distances = my_federater.create_clients(image_list = x_train_glob, label_list = y_train_glob, 

                                                             num_clients = 2, prefix_cli='Local_node', method="no-label-skew", feat_skew_method="hist-dirichlet", alpha_feat_split = 1)

Quantity skew

Creating federated data from centralized data using the MinSize-Dirichlet method.

from fedartml import SplitAsFederatedData

from keras.datasets import cifar10

import numpy as np



# Define random state for reproducibility

random_state = 0



# Load data

(x_train_glob, y_train_glob), (x_test_glob, y_test_glob) = cifar10.load_data()

y_train_glob = np.reshape(y_train_glob, (y_train_glob.shape[0],))

y_test_glob = np.reshape(y_test_glob, (y_test_glob.shape[0],))



# Normalize pixel values to be between 0 and 1

x_train_glob, x_test_glob = x_train_glob / 255.0, x_test_glob / 255.0



# Instantiate a SplitAsFederatedData object

my_federater = SplitAsFederatedData(random_state = random_state)



# Get federated dataset from centralized dataset

clients_glob_dic, list_ids_sampled_dic, miss_class_per_node, distances = my_federater.create_clients(image_list = x_train_glob, label_list = y_train_glob, 

                                                             num_clients = 2, prefix_cli='Local_node', method = "no-label-skew", quant_skew_method="minsize-dirichlet", alpha_quant_split=1)

Documentation

Find the documentation of the library on:

https://fedartml.readthedocs.io/en/latest/index.html#

Metadata

Release files for FedArtML 0.1.34

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for FedArtML 0.1.34
File Size Uploaded Provenance
FedArtML-0.1.34.tar.gz 16.2 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for FedArtML 0.1.34
File Interpreter ABI Platform
FedArtML-0.1.34-py3-none-any.whl Python 3 none any Details

Total release size: 33.2 kB

Release files / FedArtML-0.1.34.tar.gz

Download URL FedArtML-0.1.34.tar.gz
Size 16.2 kB
Tags Source
SHA-256 checksum
How to use checksums
4351c6f98bf1e716b248a1bef2843cacc8c72648362a74a88661f6072762f374
BLAKE2b-256 checksum
How to use checksums
7a9b13f39b66635aa92237ea9bad9376ff4ec87d7ec7e5507aaa260760d05469
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.10.13

Release files / FedArtML-0.1.34-py3-none-any.whl

Download URL FedArtML-0.1.34-py3-none-any.whl
Size 17.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
323fcd435ed497da9bacc9707f3c363bc43a83aae5500818cc538e8db2f8d35d
BLAKE2b-256 checksum
How to use checksums
c4189d9bd4fe7b4ae048a5c9d8d21da214f34e5ec7241b5f06c41e096ee3f9d2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.10.13

Security for FedArtML 0.1.34

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.1.34 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page