带有XGBoost的GridSearch在无限循环上产生折旧错误

时间:2018-04-18 20:38:50

标签: performance machine-learning xgboost grid-search hyperparameters

我正在尝试在XGBoost上使用GridSearchCV进行超参数调整。但是我收到了以下错误。

/usr/local/lib/python3.6/dist-packages/sklearn/preprocessing/label.py:151: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.if diff:

这一直在继续运行。以下是代码。

    classifier = xgb.XGBClassifier()

    from sklearn.grid_search import GridSearchCV
    n_estimators=[10,50,100,150,200,250,300]
    max_depth=[2,3,4,5,6,7,8,9,10]
    learning_rate=[0.1,0.01,0.09,0.08,0.07,0.001]
    colsample_bytree=[0.5,0.6,0.7,0.8,0.9]
    min_child_weight=[1,2,3,4,5,6,7,8,9,10]
    gamma=[0.001,0.01,0.1,0.2,0.3,0.4,0.5,1]
    subsample=[0.5,0.6,0.7,0.8,0.9]

    param_grid=dict(n_estimators=n_estimators,max_depth=max_depth,learning_rate=learning_rate,colsample_bytree=colsample_bytree,min_child_weight=min_child_weight,gamma=gamma,subsample=subsample)

   grid = GridSearchCV(classifier, param_grid, cv=10, scoring='accuracy')
   grid.fit(X, Y)
   grid.grid_scores_

   print(grid.best_score_)
   print(grid.best_params_)
   print(grid.best_estimator_)

   # Predicting the Test set results
   Y_pred = classifier.predict(X_test)

   # Making the Confusion Matrix
   from sklearn.metrics import confusion_matrix
   cm = confusion_matrix(Y_test, Y_pred)

我使用的是python3.5,XGBOOT和gridsearch库已经预先加载了。我在google collaboratory上运行它。

请说明出了什么问题?

0 个答案:

没有答案