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

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

0
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()
    print(format('How to check model\'s AUC score using cross validation in Python','*^82'))

    import warnings
    warnings.filterwarnings("ignore")

    # 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)

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

[0.92377622 0.91398601 0.93627451 0.92787115 0.93067227 0.92366947
 0.93207283]

0.927102449371357

0.006134475860963237

Relevant Projects

Perform Time series modelling using Facebook Prophet
In this project, we are going to talk about Time Series Forecasting to predict the electricity requirement for a particular house using Prophet.

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.

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.

Predict Employee Computer Access Needs in Python
Data Science Project in Python- Given his or her job role, predict employee access needs using amazon employee database.

Data Science Project - Instacart Market Basket Analysis
Data Science Project - Build a recommendation engine which will predict the products to be purchased by an Instacart consumer again.

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.

Time Series Forecasting with LSTM Neural Network Python
Deep Learning Project- Learn to apply deep learning paradigm to forecast univariate time series data.

Mercari Price Suggestion Challenge Data Science Project
Data Science Project in Python- Build a machine learning algorithm that automatically suggests the right product prices.

Predict Churn for a Telecom company using Logistic Regression
Machine Learning Project in R- Predict the customer churn of telecom sector and find out the key drivers that lead to churn. Learn how the logistic regression model using R can be used to identify the customer churn in telecom dataset.

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.