Federated Learning XGBoost tutorial for UI
Federated Learning XGBoost tutorial for UI This tutorial demonstrates the usage of Federated Learning with the goal of training a machine learning model with data from different users without having users share their data. The steps are done in a low code environment with the UI and with an XGBoost framework. In this tutorial you learn to: * [Step 1: Start Federated Learning as the admin](https://dataplatform.cloud.ibm.com/docs/content/wsj/analyze-data/fl-xg-tutorial.html?context=cdpaas&locale=enstep-1) * [Before you begin](https://dataplatform.cloud.ibm.com/docs/content/wsj/analyze-data/fl-xg-tutorial.html?context=cdpaas&locale=enbefore-you-begin) * [Start the aggregator](https://dataplatform.cloud.ibm.com/docs/content/wsj/analyze-data/fl-xg-tutorial.html?context=cdpaas&locale=enstart-the-aggregator) * [Step 2: Train model as a party](https://dataplatform.cloud.ibm.com/docs/content/wsj/analyze-data/fl-xg-tutorial.html?context=cdpaas&locale=enstep-2) * [Step 3: Save and deploy the model online](https://dataplatform.cloud.ibm.com/docs/content/wsj/analyze-data/fl-xg-tutorial.html?context=cdpaas&locale=enstep-3) * [Step 4: Score the model](https://dataplatform.cloud.ibm.com/docs/content/wsj/analyze-data/fl-xg-tutorial.html?context=cdpaas&locale=enstep-4) Notes: * This is a step-by-step tutorial for running a UI driven Federated Learning experiment. To see a code sample for an API driven approach, go to [Federated Learning XGBoost samples](https://dataplatform.cloud.ibm.com/docs/content/wsj/analyze-data/fl-xg-samples.html). * In this tutorial, admin refers to the user that starts the Federated Learning experiment, and party refers to one or more users who send their model results after the experiment is started by the admin. While the tutorial can be done by the admin and multiple parties, a single user can also complete a full run through as both the admin and the party. For a simpler demonstrative purpose, in the following tutorial only one data set is submitted by one party. For more information on the admin and party, see [Terminology](https://dataplatform.cloud.ibm.com/docs/content/wsj/analyze-data/fl-term.html). Step 1: Start Federated Learning In this section, you learn to start the Federated Learning experiment. Before you begin 1. Log in to [IBM Cloud](https://cloud.ibm.com/). If you don't have an account, create one with any email. 2. [Create a Watson Machine Learning service instance](https://cloud.ibm.com/catalog/services/machine-learning) if you do not have it set up in your environment. 3. Log in to [watsonx](https://dataplatform.cloud.ibm.com/home2?context=wx). 4. Use an existing [project](https://dataplatform.cloud.ibm.com/docs/content/wsj/getting-started/projects.html) or create a new one. You must have at least admin permission. 5. Associate the Watson Machine Learning service with your project. 1. In your project, click the Manage > Service & integrations. 2. Click Associate service. 3. Select your Watson Machine Learning instance from the list, and click Associate; or click New service if you do not have one to set up an instance. ![Screenshot of associating the service](https://dataplatform.cloud.ibm.com/docs/content/wsj/analyze-data/images/fl_tut_add_wml_service.png) Start the aggregator 1. Create the Federated learning experiment asset: 1. Click the Assets tab in your project. 1. Click New asset > Train models on distributed data. 2. Type a Name for your experiment and optionally a description. 3. Verify the associated Watson Machine Learning instance under Select a machine learning instance. If you don't see a Watson Machine Learning instance associated, follow these steps: 1. Click Associate a Machine Learning Service Instance. 2. Select an existing instance and click Associate, or create a New service. 3. Click Reload to see the associated service. ![Screenshot of associating the service](https://dataplatform.cloud.ibm.com/docs/content/wsj/analyze-data/images/fl_demo_2.png) 4. Click Next. 2. Configure the experiment. 1. On the Configure page, select a Hardware specification. 2. Under the Machine learning framework dropdown, select scikit-learn. 3. For the Model type, select XGBoost. 4. For the Fusion method, select XGBoost classification fusion ![Screenshot of selecting XGBoost classification](https://dataplatform.cloud.ibm.com/docs/content/wsj/analyze-data/images/fl_xg_framework.png) 3. Define the hyperparameters. 1. Set the value for the Rounds field to 5. 2. Accept the default values for the rest of the fields. ![Screenshot of selecting hyperparameters](https://dataplatform.cloud.ibm.com/docs/content/wsj/analyze-data/images/fl_xg_hyperparameters.png) 3. Click Next. 4. Select remote training systems. 1. Click Add new systems. ![Screenshot of Add RTS UI](https://dataplatform.cloud.ibm.com/docs/content/wsj/analyze-data/images/fl_demo_7.png) 2. Give your Remote Training System a name. 3. Under Allowed identities, select the user that will participate in the experiment, and then click Add. You can add as many allowed identities as participants in this Federated Experiment training instance. For this tutorial, choose only yourself. Any allowed identities must be part of the project and have at leastAdmin permission. 4. When you are finished, click Add systems. ![Screenshot of creating an RTS](https://dataplatform.cloud.ibm.com/docs/content/wsj/analyze-data/images/fl_xg_create_rts.png) 5. Return to the Select remote training systems page, verify that your system is selected, and then click Next. ![Screenshot of selecting RTS](https://dataplatform.cloud.ibm.com/docs/content/wsj/analyze-data/images/fl_xg_select_rts.png) 5. Review your settings, and then click Create. 6. Watch the status. Your Federated Learning experiment status is Pending when it starts. When your experiment is ready for parties to connect, the status will change to Setup – Waiting for remote systems. This may take a few minutes. Step 2: Train model as a party 1. Ensure that you are using the same Python version as the admin. Using a different Python version might cause compatibility issues. To see Python versions compatible with different frameworks, see [Frameworks and Python version compatibility](https://dataplatform.cloud.ibm.com/docs/content/wsj/analyze-data/fl-frames.htmlfl-py-fmwk). 2. Create a new local directory. 3. Download the Adult data set into the directory with this command: wget https://api.dataplatform.cloud.ibm.com/v2/gallery-assets/entries/5fcc01b02d8f0e50af8972dc8963f98e/data -O adult.csv. 4. Download the data handler by running wget https://raw.githubusercontent.com/IBMDataScience/sample-notebooks/master/Files/adult_sklearn_data_handler.py -O adult_sklearn_data_handler.py. 5. Install Watson Machine Learning. * If you are using Linux, run pip install 'ibm-watson-machine-learning[fl-rt22.2-py3.10]'. * If you are using Mac OS with M-series CPU and Conda, download the [installation script](https://raw.github.ibm.com/WML/federated-learning/master/docs/install_fl_rt22.2_macos.sh?token=AAAXW7VVQZF7LYMTX5VOW7DEDULLE)