-
Notifications
You must be signed in to change notification settings - Fork 321
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Summary: Implement a method which given a list of Analyses computes each and returns the resulting cards. If an Exception is encountered a MarkdownAnalysisCard with the traceback is created instead with priority DEBUG. If no list of Analyses is provided defaults are chosen. Reviewed By: lena-kashtelyan Differential Revision: D66677557
- Loading branch information
1 parent
5ac3c71
commit 3d51ca6
Showing
7 changed files
with
224 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Copyright (c) Meta Platforms, Inc. and affiliates. | ||
# | ||
# This source code is licensed under the MIT license found in the | ||
# LICENSE file in the root directory of this source tree. | ||
|
||
# pyre-strict | ||
|
||
from ax.analysis.utils import choose_analyses | ||
from ax.utils.common.testutils import TestCase | ||
from ax.utils.testing.core_stubs import ( | ||
get_branin_experiment, | ||
get_branin_experiment_with_multi_objective, | ||
) | ||
|
||
|
||
class TestUtils(TestCase): | ||
def test_choose_analyses(self) -> None: | ||
analyses = choose_analyses(experiment=get_branin_experiment()) | ||
self.assertEqual( | ||
{analysis.name for analysis in analyses}, | ||
{ | ||
"ParallelCoordinatesPlot", | ||
"InteractionPlot", | ||
"Summary", | ||
"CrossValidationPlot", | ||
}, | ||
) | ||
|
||
# Multi-objective case | ||
analyses = choose_analyses( | ||
experiment=get_branin_experiment_with_multi_objective() | ||
) | ||
self.assertEqual( | ||
{analysis.name for analysis in analyses}, | ||
{"InteractionPlot", "ScatterPlot", "Summary", "CrossValidationPlot"}, | ||
) |
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,76 @@ | ||
# Copyright (c) Meta Platforms, Inc. and affiliates. | ||
# | ||
# This source code is licensed under the MIT license found in the | ||
# LICENSE file in the root directory of this source tree. | ||
|
||
import itertools | ||
|
||
from ax.analysis.analysis import Analysis | ||
from ax.analysis.plotly.cross_validation import CrossValidationPlot | ||
from ax.analysis.plotly.interaction import InteractionPlot | ||
from ax.analysis.plotly.parallel_coordinates import ParallelCoordinatesPlot | ||
from ax.analysis.plotly.scatter import ScatterPlot | ||
from ax.analysis.summary import Summary | ||
from ax.core.experiment import Experiment | ||
from ax.core.objective import MultiObjective, ScalarizedObjective | ||
|
||
|
||
def choose_analyses(experiment: Experiment) -> list[Analysis]: | ||
""" | ||
Choose a default set of Analyses to compute based on the current state of the | ||
Experiment. | ||
""" | ||
if (optimization_config := experiment.optimization_config) is None: | ||
return [] | ||
|
||
if isinstance(optimization_config.objective, MultiObjective) or isinstance( | ||
optimization_config.objective, ScalarizedObjective | ||
): | ||
# Pareto frontiers for each objective | ||
objective_plots = [ | ||
*[ | ||
ScatterPlot(x_metric_name=x, y_metric_name=y, show_pareto_frontier=True) | ||
for x, y in itertools.combinations( | ||
optimization_config.objective.metric_names, 2 | ||
) | ||
], | ||
] | ||
|
||
other_scatters = [] | ||
|
||
interactions = [ | ||
InteractionPlot(metric_name=name) | ||
for name in optimization_config.objective.metric_names | ||
] | ||
|
||
else: | ||
objective_name = optimization_config.objective.metric.name | ||
# ParallelCoorindates and leave-one-out cross validation | ||
objective_plots = [ | ||
ParallelCoordinatesPlot(metric_name=objective_name), | ||
] | ||
|
||
# Up to six ScatterPlots for other metrics versus the objective, | ||
# prioritizing optimization config metrics over tracking metrics | ||
tracking_metric_names = [metric.name for metric in experiment.tracking_metrics] | ||
other_scatters = [ | ||
ScatterPlot( | ||
x_metric_name=objective_name, | ||
y_metric_name=name, | ||
show_pareto_frontier=False, | ||
) | ||
for name in [ | ||
*optimization_config.metrics, | ||
*tracking_metric_names, | ||
] | ||
if name != objective_name | ||
][:6] | ||
|
||
interactions = [InteractionPlot(metric_name=objective_name)] | ||
|
||
# Leave-one-out cross validation for each objective and outcome constraint | ||
cv_plots = [ | ||
CrossValidationPlot(metric_name=name) for name in optimization_config.metrics | ||
] | ||
|
||
return [*objective_plots, *other_scatters, *interactions, *cv_plots, Summary()] |
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