forked from NVIDIA/NVFlare
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'NVIDIA:main' into main
- Loading branch information
Showing
52 changed files
with
676 additions
and
756 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,10 @@ | ||
nvflare~=2.4.0rc | ||
nvflare~=2.5.0rc | ||
openmined.psi==1.1.1 | ||
pandas | ||
tensorboard | ||
torch | ||
xgboost>=2.0.0 | ||
tensorboard | ||
# require xgboost 2.2 version, for now need to install a binary build | ||
# "xgboost>=2.2" | ||
|
||
--extra-index-url https://s3-us-west-2.amazonaws.com/xgboost-nightly-builds/list.html?prefix=federated-secure/ | ||
xgboost |
3 changes: 0 additions & 3 deletions
3
examples/advanced/xgboost/histogram-based/jobs/base/app/config/config_fed_server.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 2 additions & 12 deletions
14
examples/advanced/xgboost/histogram-based/jobs/base_v2/app/config/config_fed_client.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
examples/advanced/xgboost/histogram-based/jobs/base_v2/app/custom/higgs_data_loader.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
# Copyright (c) 2024, NVIDIA CORPORATION. All rights reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import json | ||
|
||
import pandas as pd | ||
import xgboost as xgb | ||
|
||
from nvflare.app_opt.xgboost.data_loader import XGBDataLoader | ||
|
||
|
||
def _read_higgs_with_pandas(data_path, start: int, end: int): | ||
data_size = end - start | ||
data = pd.read_csv(data_path, header=None, skiprows=start, nrows=data_size) | ||
data_num = data.shape[0] | ||
|
||
# split to feature and label | ||
x = data.iloc[:, 1:].copy() | ||
y = data.iloc[:, 0].copy() | ||
|
||
return x, y, data_num | ||
|
||
|
||
class HIGGSDataLoader(XGBDataLoader): | ||
def __init__(self, data_split_filename): | ||
"""Reads HIGGS dataset and return XGB data matrix. | ||
Args: | ||
data_split_filename: file name to data splits | ||
""" | ||
self.data_split_filename = data_split_filename | ||
|
||
def load_data(self, client_id: str, training_mode: str = ""): | ||
with open(self.data_split_filename, "r") as file: | ||
data_split = json.load(file) | ||
|
||
data_path = data_split["data_path"] | ||
data_index = data_split["data_index"] | ||
|
||
# check if site_id and "valid" in the mapping dict | ||
if client_id not in data_index.keys(): | ||
raise ValueError( | ||
f"Data does not contain Client {client_id} split", | ||
) | ||
|
||
if "valid" not in data_index.keys(): | ||
raise ValueError( | ||
"Data does not contain Validation split", | ||
) | ||
|
||
site_index = data_index[client_id] | ||
valid_index = data_index["valid"] | ||
|
||
# training | ||
x_train, y_train, total_train_data_num = _read_higgs_with_pandas( | ||
data_path=data_path, start=site_index["start"], end=site_index["end"] | ||
) | ||
dmat_train = xgb.DMatrix(x_train, label=y_train) | ||
|
||
# validation | ||
x_valid, y_valid, total_valid_data_num = _read_higgs_with_pandas( | ||
data_path=data_path, start=valid_index["start"], end=valid_index["end"] | ||
) | ||
dmat_valid = xgb.DMatrix(x_valid, label=y_valid) | ||
|
||
return dmat_train, dmat_valid |
10 changes: 10 additions & 0 deletions
10
examples/advanced/xgboost/histogram-based/jobs/base_v2/meta.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"name": "xgboost_histogram_based_v2", | ||
"resource_spec": {}, | ||
"deploy_map": { | ||
"app": [ | ||
"@ALL" | ||
] | ||
}, | ||
"min_clients": 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,10 @@ | ||
nvflare~=2.4.0rc | ||
nvflare~=2.5.0rc | ||
pandas | ||
xgboost>=2.0.0 | ||
scikit-learn | ||
torch | ||
tensorboard | ||
# require xgboost 2.2 version, for now need to install a binary build | ||
# "xgboost>=2.2" | ||
|
||
--extra-index-url https://s3-us-west-2.amazonaws.com/xgboost-nightly-builds/list.html?prefix=federated-secure/ | ||
xgboost |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 0 additions & 6 deletions
6
examples/advanced/xgboost/tree-based/jobs/cyclic_base/app/config/config_fed_server.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,10 @@ | ||
nvflare~=2.4.0rc | ||
nvflare~=2.5.0rc | ||
pandas | ||
xgboost | ||
scikit-learn | ||
torch | ||
tensorboard | ||
# require xgboost 2.2 version, for now need to install a binary build | ||
# "xgboost>=2.2" | ||
|
||
--extra-index-url https://s3-us-west-2.amazonaws.com/xgboost-nightly-builds/list.html?prefix=federated-secure/ | ||
xgboost |
Oops, something went wrong.