Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BugFix] Fix README and Tabular api #315

Merged
merged 1 commit into from
Aug 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions benchmark/FedHPOB/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,14 @@ We highly recommend running FedHPO-B with conda.

### Step 0. Dependency

* FedHPO-B is built on [FederatedScope](https://github.com/alibaba/FederatedScope), please see [Installation](https://github.com/alibaba/FederatedScope#step-1-installation) for install FederatedScope.
* FedHPO-B is built on a stable [FederatedScope](https://github.com/alibaba/FederatedScope), please see [Installation](https://github.com/alibaba/FederatedScope#step-1-installation) for install FederatedScope.

```bash
git clone https://github.com/alibaba/FederatedScope.git
git checkout a653102c6b8d5421d2874077594df0b2e29401a1
cd FederatedScope
pip install -e .
```

* <u>(Optianal)</u> In order to reproduce the results in our paper, please consider installing the following packages via:

Expand Down Expand Up @@ -55,21 +62,25 @@ Fortunately, we provide tools to automatically convert from tabular data to surr
### Step3. Start running

```python
from fedhpob.config import fhb_cfg
from fedhpob.benchmarks import TabularBenchmark

#
benchmark = TabularBenchmark('cnn', 'femnist', 'avg')

# get hyperparameters space
config_space = benchmark.get_configuration_space()
config_space = benchmark.get_configuration_space(CS=True)

# get fidelity space
fidelity_space = benchmark.get_fidelity_space()
fidelity_space = benchmark.get_fidelity_space(CS=True)

# get results
res = benchmark(config_space.sample_configuration(),
fidelity_space.sample_configuration(),
fhb_cfg=fhb_cfg,
seed=12345)

print(res)

```

## Reproduce the results in our paper
Expand Down Expand Up @@ -152,5 +163,4 @@ Available tabular <Model, Dataset, Fedalgo> triplets look-up table:
| mlp | 146821@openml | avg |
| mlp | 146821@openml | opt |
| mlp | 146822@openml | avg |
| mlp | 146822@openml | opt |

| mlp | 146822@openml | opt |
18 changes: 14 additions & 4 deletions benchmark/FedHPOB/fedhpob/benchmarks/tabular_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,21 @@ def objective_function(self,

return {'function_value': function_value, 'cost': cost}

def get_configuration_space(self):
return dict2cfg(self.meta_info['configuration_space'])
def get_configuration_space(self, CS=False):
if not CS:
return self.meta_info['configuration_space']
tmp_dict = {}
for key in self.meta_info['configuration_space']:
tmp_dict[key] = list(self.meta_info['configuration_space'][key])
return dict2cfg(tmp_dict)

def get_fidelity_space(self):
return dict2cfg(self.meta_info['fidelity_space'])
def get_fidelity_space(self, CS=False):
if not CS:
return self.meta_info['fidelity_space']
tmp_dict = {}
for key in self.meta_info['fidelity_space']:
tmp_dict[key] = list(self.meta_info['fidelity_space'][key])
return dict2cfg(tmp_dict)

def get_meta_info(self):
return {
Expand Down