Created
June 2, 2022 18:30
-
-
Save kusal1990/56b5e15c72fbb6b86047e253cf5e75b0 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
# Parameters to tune for XGBoost model | |
params = {'n_estimators': [10, 50, 100, 500, 1000], | |
'learning_rate': [0.0001,0.005,0.001,0.05, 0.1]} | |
# Create a custom (MCC) metric for evaluation of the model performance while | |
# hyperparameter tuning the XGBoost model | |
mcc = make_scorer(matthews_corrcoef, greater_is_better=True) | |
# Create an XGBoost classifier object with log-loss as the loss function to minimize | |
ada_clf = AdaBoostClassifier(random_state=10) | |
# Perform stratified 5-fold cross validation | |
rand_clf = RandomizedSearchCV(ada_clf, param_distributions=params, scoring=mcc, | |
cv=5, random_state=42, return_train_score=True, | |
n_jobs=-1) | |
# Fit the model | |
rand_clf.fit(X_train, y_train) | |
print(f"Best CV score: {rand_clf.best_score_}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ok