Getting an error with xgboost DMatrix

Could you please advise me on what I should do to solve this error?
Thanks in advance!

Do you have or xgboost/ in the same directory? If so, please rename it.

Thank you so much for your prompt reply!
I wanted to clarify a bit…

I actually opened a python notebook and cloned following xgboost by the command below.
!git clone --recursive

I can see that the ‘xgboost’ directory and my python notebook file are in the same place… however, I cannot find or xgboost/ as you suggested…

Could you please guide me? Thanks a lot for your valuable time!

I can see that the ‘xgboost’ directory and my python notebook file are in the same place

That’s not good. Please move the xgboost directory to somewhere else. Otherwise Python will try to import the xgboost directory, and that won’t work. I’ve wasted many hours because of a similar problem. Avoid putting anything in the directory that has the same name as the module you’re trying to import.

1 Like

if I move ‘xgboost’ directory to another place, can I still import it using following command?
import xgboost as xgb

the name of my python notebook file is ‘xgboost.ipynb’ where I am trying import the xgboost and use it for training and test…

To import xgboost as Python module, you should install XGBoost using PIP. Please run

python -m pip install xgboost

in the terminal to install XGBoost.

1 Like

Thanks for your great help!
I have successfully installed it by your given command below.
python -m pip install xgboost

Also, I moved the cloned ‘xgboost’ directory to other location; but still getting the error.

I am using python notebook from anaconda on Mac.
Should I restart my Mac or the anaconda?

You should restart the kernel.

1 Like

It worked perfectly…
You are unbelievably helpful… I really thank you from my heart!