Future Warnings can't be suppressed - no matter what

In older versions, the xgb instant could be passed with verbosity=0 and silent=True could be passed. That worked for some.

However, I cannot get xgboost to suppress FutureWarnings.

As mentioned in the docs, I have tried this:

import xgboost as xgb

That runs with no errors.

Despite that, I get thrown several FutureWarnings.

Like this:

~/miniconda3/envs/cricket/lib/python3.11/site-packages/xgboost/data.py:312: FutureWarning: is_sparse is deprecated and will be removed in a future version. Check isinstance(dtype, pd.SparseDtype) instead. if is_sparse(dtype)

This has made Jupyter Notebook completely unusable to me while running a grid search. I don’t know when the search will end or at what iteration it is in. How can I get rid of all kinds of warnings including FutureWarnings?

I am using 2.0.0 with miniconda on Linux (Ubuntu).

I checked the value of xgb.get_config() but it shows that versbosity: 0.

I still get future warnings, and cannot meaningfully use Jupyter Notebook. I have no idea how to estimate running time.

The particular warning was addressed in the latest development version of XGBoost. You can install the nightly version by following instructions in https://xgboost.readthedocs.io/en/stable/install.html#id1.

The verbosity parameter did not work since the warning was raised from Pandas, not XGBoost. To ignore warnings from Pandas and other 3rd-party libraries, follow instructions in https://docs.python.org/3/library/warnings.html#temporarily-suppressing-warnings.

1 Like

This change is going to make it to the next version, right?

I tried the things mentioned in your link as well - to no avail.

There is actually a lot of unresolved problems areound this. What solution works in one version breaks in later ones.

I cannot find the exact links now, but I posted here only after I stumbled upon multiple (> 4) discussions on several places and they all failed.

I hope it is resolved in the dev version, and if it is resolved, I hope that the change makes it to a stable release in near future.

And thanks for your response.

Yes, the fix will be part of the next stable release.

In the meanwhile, are you able to install the nightly version of XGBoost?

1 Like

In the meanwhile, are you able to install the nightly version of XGBoost?

I have not tried. I was working on a quick personal project and was using XGBoost for that. When I used XGBoost at work last time, I probably didn’t face this issuse, because I don’t remember using a grid search for parameters. That’s why this issue wasn’t on my radar.

The next time I want to run grid search, I will install the nightly version to see if this problem is there.

And, if it is indeed coming from pandas, suppressing the warnings using python’s warnings library should have worked. I am not super familiar with these, because I don’t work primarily in tabular data.

I will report back here if I download the nightly version.


Following. I’m doing AI Prompt Engineering courses online and one of my challenges involves downloading and executing Python code that uses xgboost.

It is absolutely impossible to work with this package due to all the future warnings. I’ve done everything recommended here to turn them off and it just isn’t possible. Very annoying.

@markaaronky We are working on version 2.0.1 that removes the warnings. You can subscribe to https://github.com/dmlc/xgboost/issues/9657 for the progress. We will try to publish it as soon as possible.

In the meanwhile, consider using the nightly version of XGBoost which already has the fix.

Thank you hcho3. Great info, much appreciated!

XGBoost 2.0.1 is now released!

1 Like