Last active
November 15, 2022 16:00
-
-
Save aswalin/dda0cc67b810287e640830da9beee890 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 catboost as cb | |
cat_features_index = [0,1,2,3,4,5,6] | |
def auc(m, train, test): | |
return (metrics.roc_auc_score(y_train,m.predict_proba(train)[:,1]), | |
metrics.roc_auc_score(y_test,m.predict_proba(test)[:,1])) | |
params = {'depth': [4, 7, 10], | |
'learning_rate' : [0.03, 0.1, 0.15], | |
'l2_leaf_reg': [1,4,9], | |
'iterations': [300]} | |
cb = cb.CatBoostClassifier() | |
cb_model = GridSearchCV(cb, params, scoring="roc_auc", cv = 3) | |
cb_model.fit(train, y_train) | |
With Categorical features | |
clf = cb.CatBoostClassifier(eval_metric="AUC", depth=10, iterations= 500, l2_leaf_reg= 9, learning_rate= 0.15) | |
clf.fit(train,y_train) | |
auc(clf, train, test) | |
With Categorical features | |
clf = cb.CatBoostClassifier(eval_metric="AUC",one_hot_max_size=31, \ | |
depth=10, iterations= 500, l2_leaf_reg= 9, learning_rate= 0.15) | |
clf.fit(train,y_train, cat_features= cat_features_index) | |
auc(clf, train, test) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
hi,
Should line 16 read as "Without Categorical features" instead of "With"?