-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Sarah Krebs
committed
Jan 9, 2024
1 parent
5f5f496
commit e17b423
Showing
1 changed file
with
38 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
""" | ||
Importances | ||
^^^^^^^^^^^^^^^^^^^^ | ||
This example shows how to use the plugin Importances. | ||
Note that other plugins use the same interfaces and can be used in the same fashion. | ||
""" | ||
|
||
from deepcave.plugins.hyperparameter.importances import Importances | ||
from deepcave.runs.converters.deepcave import DeepCAVERun | ||
from pathlib import Path | ||
|
||
|
||
if __name__ == "__main__": | ||
# Instantiate the run | ||
run = DeepCAVERun.from_path(Path("logs/DeepCAVE/minimal/run_2")) | ||
|
||
objective_id = run.get_objective_ids()[0] | ||
budget_ids = run.get_budget_ids() | ||
|
||
# Instantiate the plugin | ||
plugin = Importances() | ||
inputs = plugin.generate_inputs( | ||
hyperparameter_names=run.configspace.get_hyperparameter_names(), | ||
objective_id=objective_id, | ||
budget_ids=budget_ids, | ||
method="global", | ||
n_hps=3, | ||
n_trees=10 | ||
) | ||
# Note: Filter variables are not considered. | ||
outputs = plugin.generate_outputs(run, inputs) | ||
|
||
# Finally, you can load the figure. Here, the filter variables play a role. | ||
# Alternatively: Use the matplotlib output (`load_mpl_outputs`) if available. | ||
figure = plugin.load_outputs(run, inputs, outputs) # plotly.go figure | ||
figure.write_image("examples/api/importances.png", scale=2.) | ||
# figure.show() |