How to check models Average precision score using cross validation in Python?
MODEL SELECTION DATA CLEANING PYTHON DATA MUNGING MACHINE LEARNING RECIPES PANDAS CHEATSHEET     ALL TAGS

# How to check models Average precision score using cross validation in Python?

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

0
In :
```## How to check model's Average precision score using cross validation in Python
def Snippet_137():
print()
print(format('How to check model\'s Average precision score using cross validation in Python','*^82'))

import warnings
warnings.filterwarnings("ignore")

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="average_precision", cv = 7))
mean_score = cross_val_score(dtree, X, y, scoring="average_precision", cv = 7).mean()
std_score = cross_val_score(dtree, X, y, scoring="average_precision", cv = 7).std()
print(); print(mean_score)
print(); print(std_score)

Snippet_137()
```
```**How to check model's Average precision score using cross validation in Python***

[0.88845957 0.88047835 0.9132533  0.89760678 0.89968758 0.89812809
0.88732474]

0.8953026160280041

0.0105346251221406
```

#### Relevant Projects

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

##### Loan Eligibility Prediction using Gradient Boosting Classifier
This data science in python project predicts if a loan should be given to an applicant or not. We predict if the customer is eligible for loan based on several factors like credit score and past history.

##### German Credit Dataset Analysis to Classify Loan Applications
In this data science project, you will work with German credit dataset using classification techniques like Decision Tree, Neural Networks etc to classify loan applications using R.

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

##### Data Science Project in Python on BigMart Sales Prediction
The goal of this data science project is to build a predictive model and find out the sales of each product at a given Big Mart store.

##### Predict Census Income using Deep Learning Models
In this project, we are going to work on Deep Learning using H2O to predict Census income.

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

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

##### Predict Credit Default | Give Me Some Credit Kaggle
In this data science project, you will predict borrowers chance of defaulting on credit loans by building a credit score prediction model.

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