Created
          March 2, 2021 16:27 
        
      - 
      
- 
        Save PranjalDureja0002/34d3efb92ee35d95763e35d3a4d051f5 to your computer and use it in GitHub Desktop. 
    model
  
        
  
    
      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
    
  
  
    
  | from sklearn.linear_model import LogisticRegression | |
| from sklearn.metrics import roc_auc_score | |
| 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