Fix deprecated Optuna API in hyperparameter examples#2141
Open
universeplayer wants to merge 1 commit intomicrosoft:mainfrom
Open
Fix deprecated Optuna API in hyperparameter examples#2141universeplayer wants to merge 1 commit intomicrosoft:mainfrom
universeplayer wants to merge 1 commit intomicrosoft:mainfrom
Conversation
Replace deprecated Optuna API calls with their modern equivalents: - `trial.suggest_uniform()` -> `trial.suggest_float()` - `trial.suggest_loguniform()` -> `trial.suggest_float(..., log=True)` - `optuna.Study()` -> `optuna.create_study()` These deprecated APIs were removed in Optuna v4.0 and will cause errors for users following the examples with recent Optuna versions. Ref: https://optuna.readthedocs.io/en/stable/reference/generated/optuna.trial.Trial.html Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Author
|
@microsoft-github-policy-service agree |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
trial.suggest_uniform()→trial.suggest_float()trial.suggest_loguniform()→trial.suggest_float(..., log=True)optuna.Study()→optuna.create_study()Motivation
These deprecated APIs were removed in Optuna v4.0 (changelog). Users following the hyperparameter tuning examples with recent Optuna versions will encounter
AttributeErrorexceptions.This is part of the broader effort in #1007 to refine deprecated API usage across the codebase.
Changes
examples/hyperparameter/LightGBM/hyperparameter_158.py: 8 API call replacementsexamples/hyperparameter/LightGBM/hyperparameter_360.py: 8 API call replacementsTest plan
suggest_floatwithlog=Trueproduces the same log-uniform distribution assuggest_loguniform🤖 Generated with Claude Code