Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XGBClassifier is slow and does not print any output despite passing verbose parameter

I have the following code:

from xgboost import XGBClassifier

print(df_train.shape)
print(df_train_labels.shape)

clf = clf.fit(df_train, df_train_labels, verbose=True)
print("after fit")

Here df_train and df_train_labels are pandas which I read from a CSV.

The above code prints:

(1460, 7)
(1460,)

However, nothing else is printed for 10 minutes which means the code is stuck at clf.fit so I'm assuming the algorithm shouldn't spend a long time on this.

As you can see, there are only 1460 examples, so I'm assuming the algorithm shouldn't spend a long time on this.

Furthermore, since I passed verbose=True, I would have expected the model to print some output, but that is not happening.

Any idea why there is no output printed and why XGBClassifier takes such a long time?

like image 878
octavian Avatar asked Nov 26 '22 01:11

octavian


1 Answers

Looking at the documentation: https://xgboost.readthedocs.io/en/latest/python/python_api.html#module-xgboost.sklearn

It looks like the parameter for printing the progress is called verbosity. Set it to anything from 0-3 (3 for debug).

from xgboost import XGBClassifier
model = XGBClassifier()
setattr(model, 'verbosity', 2)
like image 152
Dominik Sajovic Avatar answered Jan 10 '23 07:01

Dominik Sajovic