0

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

halfer
  • 19,824
  • 17
  • 99
  • 186
Evan Gertis
  • 1,796
  • 2
  • 25
  • 59
  • 1
    You created your own file called `xgboost.py`. You can't do that. – Tim Roberts May 28 '22 at 00:11
  • @TimRoberts is correct, if you rename your file, does it still happen then? Also you may be able to try adding an empty `__init__.py` in the directory to avoid collision (not sure) – tony May 28 '22 at 00:13

0 Answers0