Here's the code for the test set performance chart.
plt.figure(figsize=(12, 4))
df_results = pd.DataFrame(grid.cv_results_)
for score in ['mean_test_recall', 'mean_test_precision']:
plt.plot([_[1] for _ in df_results['param_class_weight']],
df_results[score],
label=score)
plt.legend();
Here's the code for the train set performance chart.
plt.figure(figsize=(12, 4))
df_results = pd.DataFrame(grid.cv_results_)
for score in ['mean_train_recall', 'mean_train_precision']:
plt.scatter(x=[_[1] for _ in df_results['param_class_weight']],
y=df_results[score.replace('test', 'train')],
label=score)
plt.legend();