text_html_output_1.png
from sklearn import ensemble

from sklearn.model_selection import GridSearchCV, RandomizedSearchCV

from sklearn.pipeline import Pipeline

import scipy as sp

import warnings

import xgboost as xgb

xgb = xgb.XGBRFRegressor()
tree = ensemble.RandomForestRegressor()
ada = ensemble.AdaBoostRegressor()
grad = ensemble.GradientBoostingRegressor()

import scipy as sp
def get_scores_and_params(pipeline, params):
    search = RandomizedSearchCV(pipeline, params, cv=3, n_iter=5, scoring='roc_auc', n_jobs=-1, verbose=2)
    search.fit(X_train, y_train)
    return (search.best_score_, search.best_params_)

pipelines = [Pipeline([('xgb', xgb)]), Pipeline([('tree', tree)]), Pipeline([('ada', ada)]), Pipeline([('grad', grad)])]
getd = [{'xgb__max_depth': sp.stats.randint(1, 11), 'xgb__n_estimators': [100, 200, 500, 1000], 'xgb__colsample_bytree': [0.5, 0.6, 0.7, 0.8]}, {'tree__n_estimators': [100, 200, 500, 1000], 'tree__min_samples_split': [2, 4, 8, 10], 'tree__min_samples_leaf': [1, 2, 3, 4]}, {'ada__learning_rate': [0.3, 0.4, 0.5, 0.7, 1], 'ada__n_estimators': [10, 50, 100, 500]}, {'grad__learning_rate': [0.1, 0.2, 0.5, 1], 'grad__max_depth': [3, 5, 7], 'grad__n_estimators': [1, 2, 3, 4]}]
warnings.filterwarnings('ignore')
for i in range(len(pipelines)):
    print(get_scores_and_params(pipelines[i], getd[i]))