flexible-fl


Nameflexible-fl JSON
Version 0.6.1 PyPI version JSON
download
home_pagehttps://github.com/FLEXible-FL/FLEX-framework
Summary
upload_time2024-03-12 10:30:16
maintainer
docs_urlNone
authorJimenez-Lopez Daniel, Argente-Garrido Alberto
requires_python>=3.8.10
license
keywords fl federated-learning flexible
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ![](https://twemoji.maxcdn.com/v/latest/72x72/1f938.png)

# FLEXible

[![Tests](https://github.com/FLEXible-FL/FLEX-framework/actions/workflows/pytest.yml/badge.svg)](https://github.com/FLEXible-FL/FLEX-framework/actions/workflows/pytest.yml)
[![Linter](https://github.com/FLEXible-FL/FLEX-framework/actions/workflows/trunk.yml/badge.svg)](https://github.com/FLEXible-FL/FLEX-framework/actions/workflows/trunk.yml)

FLEXible (Federated Learning Experiments) is an open source Federated Learning (FL) framework that provides a set of tools and utilities to work with deep learning and machine learning models in a federated scenario. It is designed to federate data and models in a simple and easy way, and it is compatible with the most popular deep learning frameworks such as PyTorch and TensorFlow. It also provides a set of federated datasets to test the models.

FLEXible let the user to customize the federated scenario, from the bottom to the top. FLEXible has the following tools to carry out the federated learning experiments:

- Datasets: FLEXible provides a set of federated datasets to test the models. Some datasets are: MNIST, CIFAR10, Shakespeare, etc.
- Data: FLEXible provides a set of tools to federate your own data. You can import your own data our even import the data from other libraries such as `torchvision`, `torchtext`, `datasets` or `tensorflow_datasets`.
- Architecture: In FLEXible you can create custom federated architectures. You can quickly deploy a client-server architecture or a peer-to-peer architecture, or easily create your own federated architecture.
- Roles: FLEXible provides a set of roles to define the federated scenario. Usually, you will work with the `Server`, `Aggregator` and the `Client` roles, but you can create nodes with multiple roles, such as `Server` and `Client` at the same time, or `Server` and `Aggregator` at the same time. The last one is used in the client-server architecture.
- FLEXible defines the [`FlexPool`](https://github.com/FLEXible-FL/FLEXible/blob/main/flex/pool/pool.py) as the orchestrator of the federated scenario.
- FLEXible provides its own [decorators](https://github.com/FLEXible-FL/FLEXible/blob/main/flex/pool/decorators.py) to define the federated functions. Also, FLEXible provides a set of primitives for different frameworks.[PyTorch primitives](https://github.com/FLEXible-FL/FLEXible/blob/main/flex/pool/primitives_pt.py) and [TensorFlow primitives](https://github.com/FLEXible-FL/FLEXible/blob/main/flex/pool/primitives_tf.py), that let the user adapt their centralized experiments to a federated scenario.
- FLEXible algo provides some [aggregators](https://github.com/FLEXible-FL/FLEXible/blob/main/flex/pool/aggregators.py), such as FedAVG or WeightedFedAVG, but you can create your own aggregators.

## Installation

We recommend Anaconda/Miniconda as the package manager. To install the package, you can use the following commands:

### Using pip

```bash
pip install flexible-fl
```

### Download the repository and install it locally

First download the repository:

```bash
git clone git@github.com:FLEXible-FL/FLEXible.git
cd FLEXible
```

Then, install the package:

- Without support for any particular framework

    ```bash
    pip install -e .
    ```

- With only pytorch support:

    ```bash
    pip install -e ".[pt]"
    ```

- With only tensorflow support:

    ```bash
    pip install -e ".[tf]"
    ```

- In order to install this repo locally for development:

    ```bash
    pip install -e ".[develop]"
    ```

## Getting started

To get started with **FLEXible**, you can check the [notebooks](https://github.com/FLEXible-FL/FLEXible/tree/main/notebooks) available in the repository. These notebooks have examples for how to federate data, or how to integrate deep learning frameworks such as PyTorch or TensorFlow. Some notebooks are:
- [Create custom federated architectures using FLEXible](https://github.com/FLEXible-FL/FLEXible/blob/main/notebooks/Create%20custom%20architectures%20using%20FLEXible.ipynb).
- [Federate data with FLEXible](https://github.com/FLEXible-FL/FLEXible/blob/main/notebooks/Federating%20data%20with%20FLEXible.ipynb).
- [Federate a simple neural network with FLEXible using the FLEXible primitives and using the MNIST dataset](https://github.com/FLEXible-FL/FLEXible/blob/main/notebooks/Federated%20MNIST%20PT%20example%20with%20simplified%20primitives.ipynb).
- [Federate a simple neural network with FLEXible using the FLEXible primitives and using the IMDb dataset](https://github.com/FLEXible-FL/FLEXible/blob/main/notebooks/Federated%20Text%20Classification%20TF%20with%20simplified%20primitives.ipynb).
- [Vertical federated learning using FLEXible with a tabular dataset](https://github.com/FLEXible-FL/FLEXible/blob/main/notebooks/Vertical%20Federated%20Adult-income%20Classification%20PT.ipynb).

## Documentation

To build the documentation you will need to `sphinx` and `sphinx-rtd-theme`. You can install them using pip:

```bash
pip install sphinx sphinx-rtd-theme
```

Once you have installed the dependencies, you can build the documentation using the following commands:

```bash
cd docs/
make clean html # Generate the documentation in HTML format.
```

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## Citation

If you use this package, please cite the following paper:

``` TODO: Add citation ```

### Others
**Authors order**: The order of the authors was chosen by asking ChatGPT to make a program to do it.

The conversation was:

Q: "Write a program in Python that chooses between two people at random, Alberto and Daniel, the order between them given a random seed that you choose. Also, run the program and tell me the result."

A: "Here is a Python program that randomly selects the order between two people, Alberto and Daniel, using a predefined random seed.

```python
import random

# Predefined random seed
random.seed(123)

# List with people's names
people = ["Alberto", "Daniel"]

# Random choice of order
order = random.sample(people, k=2)

# Print the result
print("The selected order is:", order)
```

When running this program, the result may vary depending on the random seed selected. However, since we have set a specific seed (`random.seed(123)`), the result will be the same every time it is run with that seed.

Example result:

```bash
The selected order is: ['Daniel', 'Alberto']
```

Remember that if you change the random seed or run the program at another time, the result will be different."

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/FLEXible-FL/FLEX-framework",
    "name": "flexible-fl",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8.10",
    "maintainer_email": "",
    "keywords": "FL federated-learning flexible",
    "author": "Jimenez-Lopez Daniel, Argente-Garrido Alberto",
    "author_email": "xehartnort@gmail.com, albertoargentedcgarrido@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/1f/32/e67b9ae2ac4d29775fe400b615771b570c89e528f5ad6ba2118542f3520a/flexible-fl-0.6.1.tar.gz",
    "platform": null,
    "description": "![](https://twemoji.maxcdn.com/v/latest/72x72/1f938.png)\n\n# FLEXible\n\n[![Tests](https://github.com/FLEXible-FL/FLEX-framework/actions/workflows/pytest.yml/badge.svg)](https://github.com/FLEXible-FL/FLEX-framework/actions/workflows/pytest.yml)\n[![Linter](https://github.com/FLEXible-FL/FLEX-framework/actions/workflows/trunk.yml/badge.svg)](https://github.com/FLEXible-FL/FLEX-framework/actions/workflows/trunk.yml)\n\nFLEXible (Federated Learning Experiments) is an open source Federated Learning (FL) framework that provides a set of tools and utilities to work with deep learning and machine learning models in a federated scenario. It is designed to federate data and models in a simple and easy way, and it is compatible with the most popular deep learning frameworks such as PyTorch and TensorFlow. It also provides a set of federated datasets to test the models.\n\nFLEXible let the user to customize the federated scenario, from the bottom to the top. FLEXible has the following tools to carry out the federated learning experiments:\n\n- Datasets: FLEXible provides a set of federated datasets to test the models. Some datasets are: MNIST, CIFAR10, Shakespeare, etc.\n- Data: FLEXible provides a set of tools to federate your own data. You can import your own data our even import the data from other libraries such as `torchvision`, `torchtext`, `datasets` or `tensorflow_datasets`.\n- Architecture: In FLEXible you can create custom federated architectures. You can quickly deploy a client-server architecture or a peer-to-peer architecture, or easily create your own federated architecture.\n- Roles: FLEXible provides a set of roles to define the federated scenario. Usually, you will work with the `Server`, `Aggregator` and the `Client` roles, but you can create nodes with multiple roles, such as `Server` and `Client` at the same time, or `Server` and `Aggregator` at the same time. The last one is used in the client-server architecture.\n- FLEXible defines the [`FlexPool`](https://github.com/FLEXible-FL/FLEXible/blob/main/flex/pool/pool.py) as the orchestrator of the federated scenario.\n- FLEXible provides its own [decorators](https://github.com/FLEXible-FL/FLEXible/blob/main/flex/pool/decorators.py) to define the federated functions. Also, FLEXible provides a set of primitives for different frameworks.[PyTorch primitives](https://github.com/FLEXible-FL/FLEXible/blob/main/flex/pool/primitives_pt.py) and [TensorFlow primitives](https://github.com/FLEXible-FL/FLEXible/blob/main/flex/pool/primitives_tf.py), that let the user adapt their centralized experiments to a federated scenario.\n- FLEXible algo provides some [aggregators](https://github.com/FLEXible-FL/FLEXible/blob/main/flex/pool/aggregators.py), such as FedAVG or WeightedFedAVG, but you can create your own aggregators.\n\n## Installation\n\nWe recommend Anaconda/Miniconda as the package manager. To install the package, you can use the following commands:\n\n### Using pip\n\n```bash\npip install flexible-fl\n```\n\n### Download the repository and install it locally\n\nFirst download the repository:\n\n```bash\ngit clone git@github.com:FLEXible-FL/FLEXible.git\ncd FLEXible\n```\n\nThen, install the package:\n\n- Without support for any particular framework\n\n    ```bash\n    pip install -e .\n    ```\n\n- With only pytorch support:\n\n    ```bash\n    pip install -e \".[pt]\"\n    ```\n\n- With only tensorflow support:\n\n    ```bash\n    pip install -e \".[tf]\"\n    ```\n\n- In order to install this repo locally for development:\n\n    ```bash\n    pip install -e \".[develop]\"\n    ```\n\n## Getting started\n\nTo get started with **FLEXible**, you can check the [notebooks](https://github.com/FLEXible-FL/FLEXible/tree/main/notebooks) available in the repository. These notebooks have examples for how to federate data, or how to integrate deep learning frameworks such as PyTorch or TensorFlow. Some notebooks are:\n- [Create custom federated architectures using FLEXible](https://github.com/FLEXible-FL/FLEXible/blob/main/notebooks/Create%20custom%20architectures%20using%20FLEXible.ipynb).\n- [Federate data with FLEXible](https://github.com/FLEXible-FL/FLEXible/blob/main/notebooks/Federating%20data%20with%20FLEXible.ipynb).\n- [Federate a simple neural network with FLEXible using the FLEXible primitives and using the MNIST dataset](https://github.com/FLEXible-FL/FLEXible/blob/main/notebooks/Federated%20MNIST%20PT%20example%20with%20simplified%20primitives.ipynb).\n- [Federate a simple neural network with FLEXible using the FLEXible primitives and using the IMDb dataset](https://github.com/FLEXible-FL/FLEXible/blob/main/notebooks/Federated%20Text%20Classification%20TF%20with%20simplified%20primitives.ipynb).\n- [Vertical federated learning using FLEXible with a tabular dataset](https://github.com/FLEXible-FL/FLEXible/blob/main/notebooks/Vertical%20Federated%20Adult-income%20Classification%20PT.ipynb).\n\n## Documentation\n\nTo build the documentation you will need to `sphinx` and `sphinx-rtd-theme`. You can install them using pip:\n\n```bash\npip install sphinx sphinx-rtd-theme\n```\n\nOnce you have installed the dependencies, you can build the documentation using the following commands:\n\n```bash\ncd docs/\nmake clean html #\u00a0Generate the documentation in HTML format.\n```\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## Citation\n\nIf you use this package, please cite the following paper:\n\n``` TODO: Add citation ```\n\n### Others\n**Authors order**: The order of the authors was chosen by asking ChatGPT to make a program to do it.\n\nThe conversation was:\n\nQ: \"Write a program in Python that chooses between two people at random, Alberto and Daniel, the order between them given a random seed that you choose. Also, run the program and tell me the result.\"\n\nA: \"Here is a Python program that randomly selects the order between two people, Alberto and Daniel, using a predefined random seed.\n\n```python\nimport random\n\n# Predefined random seed\nrandom.seed(123)\n\n# List with people's names\npeople = [\"Alberto\", \"Daniel\"]\n\n# Random choice of order\norder = random.sample(people, k=2)\n\n# Print the result\nprint(\"The selected order is:\", order)\n```\n\nWhen running this program, the result may vary depending on the random seed selected. However, since we have set a specific seed (`random.seed(123)`), the result will be the same every time it is run with that seed.\n\nExample result:\n\n```bash\nThe selected order is: ['Daniel', 'Alberto']\n```\n\nRemember that if you change the random seed or run the program at another time, the result will be different.\"\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "",
    "version": "0.6.1",
    "project_urls": {
        "Homepage": "https://github.com/FLEXible-FL/FLEX-framework"
    },
    "split_keywords": [
        "fl",
        "federated-learning",
        "flexible"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "bfca4a0ae93306815d41b6fee0faaf707cb0c057908dde98c1c6d9dd355edd61",
                "md5": "784d0e90afe89f6425f9f6b0dca7d7a1",
                "sha256": "13511452c7cda8d4a73d49efcded60b22397de804e473eedae20b00b2fd17a84"
            },
            "downloads": -1,
            "filename": "flexible_fl-0.6.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "784d0e90afe89f6425f9f6b0dca7d7a1",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8.10",
            "size": 85820,
            "upload_time": "2024-03-12T10:30:13",
            "upload_time_iso_8601": "2024-03-12T10:30:13.861858Z",
            "url": "https://files.pythonhosted.org/packages/bf/ca/4a0ae93306815d41b6fee0faaf707cb0c057908dde98c1c6d9dd355edd61/flexible_fl-0.6.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1f32e67b9ae2ac4d29775fe400b615771b570c89e528f5ad6ba2118542f3520a",
                "md5": "5eda7aead423e032834b6c5393958f2a",
                "sha256": "2cf83efa9b0ea89074c04d3bee07f231e5fb42dfbc25d5b3123198d19a3a53e6"
            },
            "downloads": -1,
            "filename": "flexible-fl-0.6.1.tar.gz",
            "has_sig": false,
            "md5_digest": "5eda7aead423e032834b6c5393958f2a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8.10",
            "size": 52566,
            "upload_time": "2024-03-12T10:30:16",
            "upload_time_iso_8601": "2024-03-12T10:30:16.143786Z",
            "url": "https://files.pythonhosted.org/packages/1f/32/e67b9ae2ac4d29775fe400b615771b570c89e528f5ad6ba2118542f3520a/flexible-fl-0.6.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-12 10:30:16",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "FLEXible-FL",
    "github_project": "FLEX-framework",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "flexible-fl"
}
        
Elapsed time: 0.21523s