partially initialized module 'xgboost' has no attribute 'DMatrix' (most likely due to a circular import)

267 views Asked by At

I am running into an issue using the xgboost classifer from adversarial robustness toolbox (ART).

AttributeError: partially initialized module 'xgboost' has no attribute 'DMatrix' (most likely due to a circular import)

Steps:

  1. clone the ART repo.
  2. cd into the examples dir.
  3. run the xgboost example

Expected behavior: The program should print out the accuracy for the classification of the MNIST Model.

Actual

Traceback (most recent call last):
  File "/Users/evangertis/development/PythonAutomation/ART_examples/xgboost.py", line 7, in <module>
    import xgboost as xgb
  File "/Users/evangertis/development/PythonAutomation/ART_examples/xgboost.py", line 31, in <module>
    dtrain = xgb.DMatrix(x_train, label=np.argmax(y_train, axis=1))
AttributeError: partially initialized module 'xgboost' has no attribute 'DMatrix' (most likely due to a circular import)

Screenshots

https://user-images.githubusercontent.com/39931491/170389636-a2f83954-8ed6-48ab-ac22-b1634628701d.png

System information (please complete the following information):

  • MacOS
  • Python 3.9
  • Latest commit 3ff566f
  • XGBoost: 1.5.2

I am using this example: https://github.com/Trusted-AI/adversarial-robustness-toolbox/blob/main/examples/get_started_scikit_learn.py

0

There are 0 answers