text: import matplotlib.pyplot as plt
  import seaborn as sns
  import numpy as np
  
  try:
      get_ipython().magic('matplotlib inline')
      get_ipython().magic('config InlineBackend.figure_formats = set(["retina"])')
  except NameError:
      pass
  
  def plot_classifier(model, X, Z, proba = False, xlabel = None, ylabel = None):
      # https://matplotlib.org/examples/color/colormaps_reference.html
      plt.set_cmap("RdYlBu")
      
      x_min = X[:, 0].min() - 1
      x_max = X[:, 0].max() + 1
      
      y_min = X[:, 1].min() - 1
      y_max = X[:, 1].max() + 1
      
      xx, yy = np.meshgrid(
          np.linspace(x_min, x_max, 1000),
          np.linspace(y_min, y_max, 1000)
      )
  
      if proba:
          zz = model.predict_proba(np.c_[xx.ravel(), yy.ravel()])[:, 1]
          plt.imshow(zz.reshape(xx.shape), 
                     origin = "lower", 
                     aspect = "auto", 
                     extent = (x_min, x_max, y_min, y_max), 
                     vmin = 0, 
                     vmax = 1, 
                     alpha = 0.25)
      else: 
          zz = model.predict(np.c_[xx.ravel(), yy.ravel()])
          plt.contourf(xx, yy, zz.reshape(xx.shape), 
                       alpha = 0.25, 
                       vmin = 0, 
                       vmax = 1)
  
      plt.scatter(X[:, 0], X[:, 1], c=Z)
      
      if xlabel is not None:
          plt.xlabel(xlabel)
         
      if ylabel is not None:
          plt.ylabel(ylabel)
          
      # Damit wird die Grafik genau so groß angezeigt wie der
      # schattierte Farbbereich:
      plt.xlim(x_min, x_max)
      plt.ylim(y_min, y_max)
  
      plt.show()