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

Add PED-ANOVA as the first option for importance evaluator #811

Merged
merged 4 commits into from
Feb 22, 2024
Merged
Changes from 1 commit
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
16 changes: 16 additions & 0 deletions optuna_dashboard/_importance.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@
FastFanovaImportanceEvaluator = None # type: ignore


try:
from optuna.importance import PedAnovaImportanceEvaluator
except ImportError:
_logger.warning(f"optuna>=3.6.0 is required for PedAnovaImportanceEvaluator.")
PedAnovaImportanceEvaluator = None # type: ignore
except Exception as e:
_logger.warning(f"Skipping to use PedAnovaImportanceEvaluator due to {e}.")
PedAnovaImportanceEvaluator = None # type: ignore

Check warning on line 36 in optuna_dashboard/_importance.py

View check run for this annotation

Codecov / codecov/patch

optuna_dashboard/_importance.py#L34-L36

Added lines #L34 - L36 were not covered by tests
Copy link
Member

@c-bata c-bata Feb 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
except Exception as e:
_logger.warning(f"Skipping to use PedAnovaImportanceEvaluator due to {e}.")
PedAnovaImportanceEvaluator = None # type: ignore

[nit] I would say these lines can be removed since PedAnovaImportanceEvaluator is a pure Python module.



if TYPE_CHECKING:
from typing import Callable
from typing import Optional
Expand Down Expand Up @@ -64,6 +74,12 @@
*,
target: Optional[Callable[[FrozenTrial], float]] = None,
) -> dict[str, float]:
if PedAnovaImportanceEvaluator is not None:

Check warning on line 77 in optuna_dashboard/_importance.py

View check run for this annotation

Codecov / codecov/patch

optuna_dashboard/_importance.py#L77

Added line #L77 was not covered by tests
# TODO(nabenabe0928): We might want to pass baseline_quantile as an argument in the future.
return get_param_importances(

Check warning on line 79 in optuna_dashboard/_importance.py

View check run for this annotation

Codecov / codecov/patch

optuna_dashboard/_importance.py#L79

Added line #L79 was not covered by tests
study, target=target, evaluator=PedAnovaImportanceEvaluator()
)

if FastFanovaImportanceEvaluator is not None:
try:
evaluator = FastFanovaImportanceEvaluator(completed_trials=completed_trials)
Expand Down
Loading