Reputation: 475
I ran mod.fit(X, y)
and received the error:
"TypeError: range() integer end argument expected, got float."
(see stacktrace below). There doesn't appear to be anything wrong with the X
and y
inputs. The error appears to be something in the xgboost code. It's successfully fit other models, but I recently installed it via conda:
conda install -c conda-forge xgboost
I'm running python 2.7.11 on MacOS 10.10.5.
The model parameters are:
{ 'base_score': 5.0,
'booster': 'gbtree',
'colsample_bylevel': 1,
'colsample_bytree': 1,
'gamma': 0,
'learning_rate': 0.07500000000000001,
'max_delta_step': 0,
'max_depth': 4,
'min_child_weight': 1,
'missing': None,
'n_estimators': 75.0,
'n_jobs': -1,
'nthread': None,
'objective': 'reg:linear',
'random_state': 0,
'reg_alpha': 0,
'reg_lambda': 1,
'scale_pos_weight': 1,
'seed': 0,
'silent': True,
'subsample': 1
}
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-30-38afa4aff6db> in <module>()
----> 1 mod.fit(X_train.values, y_train.values)
/Users/chriseal/anaconda/lib/python2.7/site-packages/xgboost/sklearn.pyc in fit(self, X, y, eval_set, eval_metric, early_stopping_rounds, verbose)
249 early_stopping_rounds=early_stopping_rounds,
250 evals_result=evals_result, obj=obj, feval=feval,
--> 251 verbose_eval=verbose)
252
253 if evals_result:
/Users/chriseal/anaconda/lib/python2.7/site-packages/xgboost/training.pyc in train(params, dtrain, num_boost_round, evals, obj, feval, maximize, early_stopping_rounds, evals_result, verbose_eval, learning_rates, xgb_model, callbacks)
203 evals=evals,
204 obj=obj, feval=feval,
--> 205 xgb_model=xgb_model, callbacks=callbacks)
206
207
/Users/chriseal/anaconda/lib/python2.7/site-packages/xgboost/training.pyc in _train_internal(params, dtrain, num_boost_round, evals, obj, feval, xgb_model, callbacks)
62 cb for cb in callbacks if not cb.__dict__.get('before_iteration', False)]
63
---> 64 for i in range(start_iteration, num_boost_round):
65 for cb in callbacks_before_iter:
66 cb(CallbackEnv(model=bst,
TypeError: range() integer end argument expected, got float.
Upvotes: 1
Views: 825
Reputation: 475
I just figured it out. I was iterating through hyperparameters and n_estimators
was a float
(75.0) and not an integer (75). Easy fix!
Upvotes: 2