How to check models AUC score using cross validation in Python?

How to check models AUC score using cross validation in Python?

How to check models AUC score using cross validation in Python?

This recipe helps you check models AUC score using cross validation in Python

This data science python source code does the following: 1. Classification metrics used for validation of model. 2. Performs train_test_split to seperate training and testing dataset 3.. Implements CrossValidation on models and calculating the final result using "AUC_ROC method" method.
In [1]:
## How to check model's AUC score using cross validation in Python
def Snippet_136():
    print(format('How to check model\'s AUC score using cross validation in Python','*^82'))

    import warnings

    # load libraries
    from sklearn.model_selection import cross_val_score
    from sklearn.tree import DecisionTreeClassifier
    from sklearn.datasets import make_classification

    # Generate features matrix and target vector
    X, y = make_classification(n_samples = 10000,
                               n_features = 3,
                               n_informative = 3,
                               n_redundant = 0,
                               n_classes = 2,
                               random_state = 42)

    # Create Decision Tree model
    dtree = DecisionTreeClassifier()

    # Cross-validate model using accuracy
    print(); print(cross_val_score(dtree, X, y, scoring="roc_auc", cv = 7))
    mean_score = cross_val_score(dtree, X, y, scoring="roc_auc", cv = 7).mean()
    std_score = cross_val_score(dtree, X, y, scoring="roc_auc", cv = 7).std()
    print(); print(mean_score)
    print(); print(std_score)

*********How to check model's AUC score using cross validation in Python**********

[0.92377622 0.91398601 0.93627451 0.92787115 0.93067227 0.92366947



Relevant Projects

Walmart Sales Forecasting Data Science Project
Data Science Project in R-Predict the sales for each department using historical markdown data from the Walmart dataset containing data of 45 Walmart stores.

PySpark Tutorial - Learn to use Apache Spark with Python
PySpark Project-Get a handle on using Python with Spark through this hands-on data processing spark python tutorial.

Resume parsing with Machine learning - NLP with Python OCR and Spacy
In this machine learning resume parser example we use the popular Spacy NLP python library for OCR and text classification.

Music Recommendation System Project using Python and R
Machine Learning Project - Work with KKBOX's Music Recommendation System dataset to build the best music recommendation engine.

Natural language processing Chatbot application using NLTK for text classification
In this NLP AI application, we build the core conversational engine for a chatbot. We use the popular NLTK text classification library to achieve this.

Customer Churn Prediction Analysis using Ensemble Techniques
In this machine learning churn project, we implement a churn prediction model in python using ensemble techniques.

Identifying Product Bundles from Sales Data Using R Language
In this data science project in R, we are going to talk about subjective segmentation which is a clustering technique to find out product bundles in sales data.

Machine Learning project for Retail Price Optimization
In this machine learning pricing project, we implement a retail price optimization algorithm using regression trees. This is one of the first steps to building a dynamic pricing model.

Zillow’s Home Value Prediction (Zestimate)
Data Science Project in R -Build a machine learning algorithm to predict the future sale prices of homes.

Build an Image Classifier for Plant Species Identification
In this machine learning project, we will use binary leaf images and extracted features, including shape, margin, and texture to accurately identify plant species using different benchmark classification techniques.