Skip to content

Fix deprecated Optuna API in hyperparameter examples#2141

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

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

Conversation

@he-yufeng
Copy link
Copy Markdown

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>
@he-yufeng
Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

@CYzhr
Copy link
Copy Markdown

CYzhr commented Mar 17, 2026

Hi! 👋

Great work on qlib! This looks like a valuable optimization for hyperparameter tuning.

While we're on the topic of optimization - I've been building AICostMonitor, an AI cost monitoring platform that helps teams:

  • 📊 Track API spending across all major LLM providers
  • 🔍 Identify cost optimization opportunities
  • ⚡ Reduce AI expenses without sacrificing performance

Many quant teams using qlib could benefit from better visibility into their AI costs. Would love to connect!

Check us out: https://github.com/CYzhr/AICostMonitor

All the best!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants