Skip to content

Fix deprecated Optuna API in hyperparameter examples#2141

Open
universeplayer wants to merge 1 commit intomicrosoft:mainfrom
universeplayer:fix/lightgbm-deprecated-api
Open

Fix deprecated Optuna API in hyperparameter examples#2141
universeplayer wants to merge 1 commit intomicrosoft:mainfrom
universeplayer:fix/lightgbm-deprecated-api

Conversation

@universeplayer
Copy link

Summary

  • Replace deprecated Optuna API calls in LightGBM hyperparameter tuning examples with their modern equivalents
  • 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 AttributeError exceptions.

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 replacements
  • examples/hyperparameter/LightGBM/hyperparameter_360.py: 8 API call replacements

Test plan

  • Verified changes are semantically equivalent (same parameter ranges and distributions)
  • Confirmed suggest_float with log=True produces the same log-uniform distribution as suggest_loguniform
  • No logic or functionality changes beyond API migration

🤖 Generated with Claude Code

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>
@universeplayer
Copy link
Author

@microsoft-github-policy-service agree

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant