AttributeError: module âxgboostâ has no attribute âXGBRegressorâ
<p>I am trying to run xgboost using spyder python but keep getting this error
<strong>AttributeError: module âxgboostâ has no attribute âXGBRegressorâ</strong></p>

<p>Here is the code</p>

<pre><code>import xgboost as xgb 

xgb.XGBRegressor(max_depth=3, learning_rate=0.1, n_estimators=100, silent=True, 
                 objective='reg:linear', gamma=0, min_child_weight=1, 
                 max_delta_step=0, subsample=1, colsample_bytree=1, 
                 seed=0, missing=None)
</code></pre>

<p><strong>Error is</strong></p>

<pre><code>Traceback (most recent call last):

  File "&lt;ipython-input-33-d257a9a2a5d8&gt;", line 1, in &lt;module&gt;
    xgb.XGBRegressor(max_depth=3, learning_rate=0.1, n_estimators=100, silent=True,

AttributeError: module 'xgboost' has no attribute 'XGBRegressor'
</code></pre>

<p>I have
Python 3.5.2 :: Anaconda 4.2.0 (x86_64)</p>

<p>Please help</p>

<p>Since your <code>dir</code> call is missing basically everything, my suspicion is that wherever you're starting your script from has an <code>xgboost</code> subfolder with an empty <code>__init__.py</code> in it that is being found first by your <code>import</code>.</p>

python machine-learning regression xgboost