5. Model Validation and Optimization
Activity 5.01: Hyperparameter Tuning and Model Selection
Solution:
- Create a new Jupyter notebook and load the following libraries:
import pandas as pd import numpy as np import datetime import time import os import matplotlib.pyplot as plt %matplotlib inline import seaborn as sns %config InlineBackend.figure_format='retina' sns.set() # Revert to matplotlib defaults plt.rcParams['figure.figsize'] = (9, 6) plt.rcParams['axes.labelpad'] = 10 sns.set_style("darkgrid") %load_ext watermark %watermark -d -v -m -p \ numpy,pandas,matplotlib,seaborn,sklearn
- Load the preprocessed Human Resource Analytics dataset by running the following code:
df = pd.read_csv('../data/hr-analytics/hr_data_processed_pca.csv') df.columns
This displays the following output:
- Select the features to include in the model and perform a train-test split on the data...