Skip to content

Commit

Permalink
Merge branch 'main' into checkpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
geoalgo committed Oct 11, 2023
2 parents 4472b09 + 2bc3343 commit c3fc9ca
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 4 deletions.
10 changes: 7 additions & 3 deletions examples/launch_plot_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,16 @@

tuning_experiment = load_experiment(tuner.name)

# Print the best configuration found from experiment-results
# prints the best configuration found from experiment-results
print(f"best result found: {tuning_experiment.best_config()}")

# Plot the best value found over time
# plots the best metric over time
tuning_experiment.plot()

# Print the best configuration found from the tuner and retrain it
# plots values found by all trials over time
tuning_experiment.plot_trials_over_time()

# prints the best configuration found from the tuner and retrains it
trial_id, best_config = tuner.best_config()
tuner.trial_backend.start_trial(config=best_config)

1 change: 0 additions & 1 deletion examples/launch_smac_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ def run_smac_simulated_backend():
dataset=dataset_name,
)

# Asynchronous successive halving (ASHA)
blackbox = trial_backend.blackbox

scheduler = SMAC(
Expand Down
3 changes: 3 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ def load_benchmark_requirements():
required_moo = load_requirements("requirements-moo.txt")
required_visual = load_requirements("requirements-visual.txt")
required_sklearn = load_requirements("requirements-sklearn.txt")
required_smac = load_requirements("requirements-smac.txt")

# Do not add SMAC for now in "extra" as it can easily conflict with Yahpo config-space version
required_extra = (
required_gpsearchers
+ required_kde
Expand Down Expand Up @@ -95,6 +97,7 @@ def load_benchmark_requirements():
"bore": required_bore,
"extra": required_extra,
"basic": required_basic,
"smac": required_smac,
},
install_requires=required_core,
include_package_data=True,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# TODO uncomment once https://github.com/slds-lmu/yahpo_gym/pull/83 is released in Yahpo
# onnxruntime>=1.10.0
onnxruntime==1.10.0
pyyaml
configspace<=0.6.1
Expand Down
39 changes: 39 additions & 0 deletions syne_tune/experiments/experiment_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,45 @@ def plot(
else:
fig.show()

def plot_trials_over_time(
self, metric_to_plot: Union[str, int] = 0, figure_path: str = None, figsize=None
):
"""Plot trials results over as function of wallclock time
:param metric_to_plot: Indicates which metric to plot, can be the index or a name of the metric.
default to 0 - first metric defined
:param figure_path: If specified, defines the path where the figure will be saved.
If None, the figure is shown
:param figsize: width and height of figure
"""
_, metric_name, metric_mode = self._metric_name_mode(
metric_to_plot, verbose=True
)
df = self.results

fig, ax = plt.subplots(1, 1, figsize=figsize if figsize else (12, 4))
for trial_id in sorted(df.trial_id.unique()):
df_trial = df[df.trial_id == trial_id]
df_trial.plot(
x=ST_TUNER_TIME,
y=metric_name,
marker=".",
ax=ax,
legend=None,
alpha=0.5,
)
df_stop = df[df["st_decision"] == "STOP"]
plt.scatter(
df_stop[ST_TUNER_TIME], df_stop[metric_name], marker="x", color="red"
)
plt.xlabel("Wallclock time (s)")
plt.ylabel(metric_name)
plt.title("Trials value over time")
if figure_path is not None:
fig.savefig(figure_path)
else:
fig.show()

def metric_mode(self) -> Union[str, List[str]]:
return self.metadata["metric_mode"]

Expand Down

0 comments on commit c3fc9ca

Please sign in to comment.