Skip to content

[python-package] verbose does not supress warnings with custom objectives #6014

@lbittarello

Description

@lbittarello

Description

In the Python package of LightGBM 4.0.0, setting the verbose parameter to -1 does not suppress warnings if the objective is a user-defined function.

Reproducible example

import numpy as np
import pandas as pd

from lightgbm import LGBMRegressor

df = pd.DataFrame({"x": [0, 0, 1, 1, 1], "y": [0, 1, 0, 1, 1]})


def l2_obj(y_true, y_pred):
    grad = y_pred - y_true
    hess = np.ones_like(y_pred)
    return grad, hess


estimator = LGBMRegressor(
    objective=l2_obj, min_child_samples=1, n_estimators=1, n_jobs=1, verbose=-1
)

estimator.fit(df[["x"]], df["y"])

Environment info

LightGBM version or commit hash: 4.0.0

Command(s) you used to install LightGBM

conda install -y lightgbm

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions