Chapter 6: Model Evaluation
Activity 15: Final Test Project
Solution
Import the relevant libraries:
import pandas as pd import numpy as np import json %matplotlib inline import matplotlib.pyplot as plt from sklearn.preprocessing import OneHotEncoder from sklearn.model_selection import RandomizedSearchCV, train_test_split from sklearn.ensemble import GradientBoostingClassifier from sklearn.metrics import (accuracy_score, precision_score, recall_score, confusion_matrix, precision_recall_curve)
Read the attrition_train.csv dataset. Read the CSV file into a DataFrame and print the .info() of the DataFrame:
data = pd.read_csv('attrition_train.csv') data.info()The output will be as follows:

Figure 6.33: Output of info()
Read the JSON file with the details of the categorical variables. The JSON file contains a dictionary, where the keys are the column names of the categorical features and the corresponding values are the list of categories in the feature. This file will help us one-hot encode the categorical...