Skip to content

Instantly share code, notes, and snippets.

@aswalin
Last active November 15, 2022 16:00
Show Gist options
  • Save aswalin/dda0cc67b810287e640830da9beee890 to your computer and use it in GitHub Desktop.
Save aswalin/dda0cc67b810287e640830da9beee890 to your computer and use it in GitHub Desktop.
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)
@aisobe
Copy link

aisobe commented Oct 4, 2020

hi,
Should line 16 read as "Without Categorical features" instead of "With"?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment