code: def make_heatmap(ax, gs, is_sh=False, make_cbar=False):
      """Helper to make a heatmap."""
      results = pd.DataFrame(gs.cv_results_)
      results[["param_C", "param_gamma"]] = results[
          ["param_C", "param_gamma"]
      ].astype(np.float64)
      if is_sh:
          # SH dataframe: get mean_test_score values for the highest iter
          scores_matrix = results.sort_values("iter").pivot_table(
              index="param_gamma",
              columns="param_C",
              values="mean_test_score",
              aggfunc="last",
          )
      else:
          scores_matrix = results.pivot(
              index="param_gamma",
              columns="param_C",
              values="mean_test_score",
          )
  
      im = ax.imshow(scores_matrix)
  
      ax.set_xticks(np.arange(len(Cs)))
      ax.set_xticklabels(["{:.0E}".format(x) for x in Cs])
      ax.set_xlabel("C", fontsize=15)
  
      ax.set_yticks(np.arange(len(gammas)))
      ax.set_yticklabels(["{:.0E}".format(x) for x in gammas])
      ax.set_ylabel("gamma", fontsize=15)
  
      # Rotate the tick labels and set their alignment.
      plt.setp(
          ax.get_xticklabels(),
          rotation=45,
          ha="right",
          rotation_mode="anchor",
      )
  
      if is_sh:
          iterations = results.pivot_table(
              index="param_gamma",
              columns="param_C",
              values="iter",
              aggfunc="max",
          ).values
          for i in range(len(gammas)):
              for j in range(len(Cs)):
                  ax.text(
                      j,
                      i,
                      iterations[i, j],
                      ha="center",
                      va="center",
                      color="w",
                      fontsize=20,
                  )
  
      if make_cbar:
          fig.subplots_adjust(right=0.8)
          cbar_ax = fig.add_axes([0.85, 0.15, 0.05, 0.7])
          fig.colorbar(im, cax=cbar_ax)
          cbar_ax.set_ylabel(
              "mean_test_score", rotation=-90, va="bottom", fontsize=15
          )
  
file_path: scikit-learn/examples/model_selection/plot_successive_halving_heatmap.py
imports: from time import time
  import matplotlib.pyplot
  import numpy
  import pandas
  from sklearn import datasets
  from sklearn.experimental import enable_halving_search_cv
  from sklearn.model_selection import GridSearchCV, HalvingGridSearchCV
  from sklearn.svm import SVC
label_desc: Use image node_id 1 for calling a global function with example usage: make_heatmap(ax, gs, is_sh, make_cbar) without return types