As k-fold cross-validation method proved to be a better method, it is more suitable for comparing models. The reason behind this is that k-fold cross-validation gives much estimation of the evaluation metrics, and on averaging these estimations, we get a better assessment of model performance.
The following shows the code used to import libraries for comparing models:
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
%matplotlib inline
After importing libraries, we'll import the diamond dataset. The following shows the code used to prepare this diamond dataset:
# importing data
data_path= '../data/diamonds.csv'
diamonds = pd.read_csv(data_path)
diamonds = pd.concat([diamonds, pd.get_dummies(diamonds['cut'], prefix='cut', drop_first=True)],axis=1)
diamonds = pd.concat([diamonds, pd.get_dummies...