visualize ROC AUC from oversampled dataset and cross validated model

Viewed 17

so what i want to do is to oversample, and cross validate and visualize the roc auc graph.

i did oversample and cross validate using pipeline because they said its the best practice to oversample while cross validating. But i dont know how to visualize the roc auc graph. i dont actually know if its possible to visualize it after cross validation.

so what should i add to my code to visualize the roc auc graph?

this is my code :

skf= StratifiedKFold(n_splits=10)

# cross validation function
def upsamplingCrossVal(clf, X, Y, clfname):

    # mmaking pipeline
    pipeline = make_pipeline(SMOTEN(),
                            clf)
    
    # cross validation
    cv_acc = cross_val_score(pipeline, X, Y, scoring='accuracy', cv= skf)
    cv_prec = cross_val_score(pipeline, X, Y, scoring='precision', cv= skf)
    cv_rec = cross_val_score(pipeline, X, Y, scoring='recall', cv= skf)
    cv_f1 = cross_val_score(pipeline, X, Y, scoring='f1', cv= skf)
    cv_roc = cross_val_score(pipeline, X, Y, scoring='roc_auc', cv= skf)
    
    print('# ',clfname)

    print("\n")
    print("# accuracy mean : ",cv_acc.mean()*100)
    print("# precision mean : ",cv_prec.mean()*100)
    print("# recall mean : ",cv_rec.mean()*100)
    print("# f1 score mean : ",cv_f1.mean())
    print("# roc auc mean : ",cv_roc.mean())

    print("\n")

and then i execute the function with these codes :

upsamplingCrossVal(model_c45, X_train, y_train, 'decision tree c4.5')
upsamplingCrossVal(model_cart, X_train, y_train, 'decision tree cart')
upsamplingCrossVal(model_rf, X_train, y_train, 'random forest')
upsamplingCrossVal(model_nb, X_train, y_train, 'Naive Bayes')
upsamplingCrossVal(model_lr, X_train, y_train, 'Logistic Regression')

im new at this, im open to feedback, critiques and correction. thankyou!

0 Answers
Related