> For the complete documentation index, see [llms.txt](https://medomicslab.gitbook.io/medfl-app-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://medomicslab.gitbook.io/medfl-app-docs/medfl-review/medfl-package-review.md).

# MEDfl package review

Step-by-step validation of the MEDfl Python package, including installation, dataset setup, and execution in both simulation and real-world modes.

This section presents the review of the **MEDfl Python package**, including installation, dataset configuration, and execution of federated learning experiments.

The package will be tested in two modes:

* **Simulation mode**
* **Real-world distributed mode**

Follow the steps below to install MEDfl and begin the review process.

### Environment Setup (Recommended)

Before installing MEDfl, it is strongly recommended to create a **virtual environment (venv)**.

MEDfl installs several dependencies in the background.\
Using a virtual environment helps Prevent version conflicts with packages already installed on your machine

#### Create the environment

```bash
python -m venv medfl_env
```

This creates a new isolated environment named `medfl_env`.

{% tabs %}
{% tab title="Linux" %}

```shellscript
source medfl_env/bin/activate
```

{% endtab %}

{% tab title="Mac" %}

```shellscript
source medfl_env/bin/activate
```

{% endtab %}

{% tab title="Windows" %}

```shellscript
medfl_env\Scripts\activate
```

{% endtab %}
{% endtabs %}

After activation, your terminal should display:

```
(medfl_env)
```

This indicates that the virtual environment is active.

### Install MEDfl from [PyPI](https://pypi.org/project/medfl/)

The package can be installed directly with pip.&#x20;

{% hint style="warning" %}
Confirm your Python version matches the package requirements shown on the PyPI page.
{% endhint %}

```bash
pip install MEDfl
```

After installing MEDfl, verify that the package is correctly installed and accessible in your Python environment.

```bash
pip show MEDfl
```

This should display:

* package name: `medfl`
* installed version
* installation location

If nothing is returned, the package is not installed in the current environment.

Open a Python shell or a notebook and run:

```python
import medfl
print(medfl.__version__)
```

### Datasets used in this review

This tutorial uses a **binary classification dataset for diabetes prediction** publicly available on [**Kaggle**](https://www.kaggle.com/datasets/iammustafatz/diabetes-prediction-dataset?resource=download)

#### Task

* **Objective:** Predict whether a patient has diabetes
* **Target variable:** `diabetes`
  * `0` → No diabetes
  * `1` → Diabetes

#### Features

* **Number of input variables:** 8&#x20;

  ```csv
  gender,age,hypertension,heart_disease,smoking_history,bmi,HbA1c_level,blood_glucose_level
  ```
* All features are used as predictors during training, while the target column is excluded from the input space.&#x20;

  ```csv
  diabetes
  ```

#### Federated Data Distribution

To simulate a realistic federated learning scenario, the dataset is **partitioned across three clients**, each representing a different medical institution:

| Client   | Number of Samples | Link                                                                                                       |
| -------- | ----------------- | ---------------------------------------------------------------------------------------------------------- |
| Client 1 | 7,209             | [Dataset1](https://github.com/ouaelesi/MEDfl-package-review/blob/master/data/clients/client_1_dataset.csv) |
| Client 2 | 6,361             | [Dataset2](https://github.com/ouaelesi/MEDfl-package-review/blob/master/data/clients/client_2_dataset.csv) |
| Client 3 | 5,868             | [Dataset3](https://github.com/ouaelesi/MEDfl-package-review/blob/master/data/clients/client_3_dataset.csv) |

Each client trains locally on its own subset of data, and **no raw data is shared** between clients during training.

### Execution Modes for MEDfl package review

For the package review, MEDfl is evaluated under two execution modes: a simulation mode for controlled and reproducible experiments, and a real-world mode that reflects distributed training across actual client environments.

<table data-view="cards"><thead><tr><th></th><th></th><th data-hidden data-card-cover data-type="image">Cover image</th></tr></thead><tbody><tr><td>MEDfl package </td><td><blockquote><p><a href="/medfl-app-docs/medfl-review/medfl-package-review/simulation.md"><em><mark style="color:yellow;"><strong>Simulation</strong></mark></em></a> </p></blockquote></td><td><a href="https://2289920470-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOpYh7tOQkAu0q6hPpqe9%2Fuploads%2FmZDDN9NfU96fIhnT5eRA%2FDiagramme%20sans%20nom.drawio%20(1).png?alt=media&amp;token=9bf5b5bf-47e9-49e0-8970-e168a2ba0ce2">Diagramme sans nom.drawio (1).png</a></td></tr><tr><td>MEDfl package</td><td><blockquote><p><a href="/medfl-app-docs/medfl-review/medfl-package-review/real-world.md"><em><mark style="color:$success;"><strong>Real world</strong></mark></em></a></p></blockquote></td><td><a href="https://2289920470-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOpYh7tOQkAu0q6hPpqe9%2Fuploads%2FmZDDN9NfU96fIhnT5eRA%2FDiagramme%20sans%20nom.drawio%20(1).png?alt=media&amp;token=9bf5b5bf-47e9-49e0-8970-e168a2ba0ce2">Diagramme sans nom.drawio (1).png</a></td></tr></tbody></table>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://medomicslab.gitbook.io/medfl-app-docs/medfl-review/medfl-package-review.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `build a script that syncs our docs to a CMS` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
