Created
October 12, 2022 19:53
-
-
Save Abhayparashar31/f5800e9c5a9ef149d0564565a6066030 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import xgboost as xgb | |
from sklearn.model_selection import RandomizedSearchCV | |
params = {'max_depth': [3, 6, 8,10,12], | |
'learning_rate': [0.01, 0.1, 0.2, 0.001, 0.3], | |
'colsample_bytree': np.arange(0.3, 1.0, 0.1), | |
'colsample_bylevel': np.arange(0.3, 1.0, 0.1), | |
'subsample': np.arange(0.3, 1.0, 0.1), | |
'n_estimators': [100, 150, 200, 250,300] | |
} | |
xgbclf = xgb.XGBClassifier(objective="multi:softmax", tree_method='hist') | |
clf = RandomizedSearchCV(estimator=xgbclf, | |
param_distributions=params, | |
scoring='accuracy', | |
n_iter=20, | |
n_jobs=4, | |
verbose=2) | |
clf.fit(x_train, y_train) | |
best_combination = clf.best_params_ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment