Skip to content

Instantly share code, notes, and snippets.

@PranjalDureja0002
Created March 15, 2021 10:02
Show Gist options
  • Save PranjalDureja0002/a835e1a7d7dd4cbcd8d2a45b03d3735d to your computer and use it in GitHub Desktop.
Save PranjalDureja0002/a835e1a7d7dd4cbcd8d2a45b03d3735d to your computer and use it in GitHub Desktop.
model
x_cfl=XGBClassifier(n_estimators=1000,nthread=-1)
x_1=XGBClassifier(n_estimators=500,nthread=-1)
x_2=XGBClassifier(n_estimators=500,nthread=-1)
x_3 = DecisionTreeClassifier(max_depth=best_depth,min_samples_split=best_samples,class_weight='balanced')
x_4 = LogisticRegression(class_weight='balanced')
s_clf = StackingClassifier(classifiers=[x_1,x_2,x_3,x_4],meta_classifier=x_cfl)
s_clf.fit(X_train,y_train)
#sig_clf = CalibratedClassifierCV(x_cfl, method="sigmoid")
#sig_clf.fit(X_train_f, y_train_f)
y_train_pred = pred_func(s_clf,X_train)
y_test_pred = pred_func(s_clf,X_test)
print ("The train roc_auc Score is:",roc_auc_score(y_train, y_train_pred ))
print("***********************")
print("The test roc_auc Score is",roc_auc_score(y_test,y_test_pred))
print("***********************")
y_train_pred = s_clf.predict(X_train)
y_test_pred = s_clf.predict(X_test)
print ("The train f1 Score is:",f1_score(y_train, y_train_pred,average='macro'))
print("***********************")
print ("The test f1 Score is:",f1_score(y_test, y_test_pred,average='macro'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment