Created
June 2, 2022 18:26
-
-
Save kusal1990/8a7beb129ebbcd0e21824463a8280df9 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
# hyperparameter tuning the XGBoost model | |
params ={'C':[10 ** x for x in range(-5, 3)],'gamma':[10 ** x for x in range(-5, 3)]} | |
# Create a custom (MCC) metric for evaluation of the model performance while | |
mcc = make_scorer(matthews_corrcoef, greater_is_better=True) | |
# Create an XGBoost classifier object with log-loss as the loss function to minimize | |
svm_clf = svm.SVC(random_state=42,kernel='rbf',class_weight='balanced') | |
# Perform stratified 5-fold cross validation | |
grid_clf = GridSearchCV(svm_clf, params, scoring=mcc, cv=5, return_train_score=True) | |
# Fit the model | |
grid_clf .fit(X_train, y_train) | |
print(f"Best CV score: {grid_clf.best_score_}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ok