There's more...

  1. For additional insight, we will create an additional visualization. Start by creating a NumPy mesh grid as follows:
grid_interval = 0.02x_min, x_max = X[:, 0].min() - .5, X[:, 0].max() + .5y_min, y_max = X[:, 1].min() - .5, X[:, 1].max() + .5xmin, xmax = np.percentile(X[:, 0], [0, 100])ymin, ymax = np.percentile(X[:, 1], [0, 100])xmin_plot, xmax_plot = xmin - .5, xmax + .5ymin_plot, ymax_plot = ymin - .5, ymax + .5xx, yy = np.meshgrid(np.arange(xmin_plot, xmax_plot, grid_interval),np.arange(ymin_plot, ymax_plot, grid_interval))
  1. Using the best_estimator_ attribute in the grid search, predict the scenarios on the NumPy grid that was just created:
test_preds = gs_inst.best_estimator_.predict(np.array(zip(xx.ravel(), yy.ravel()))) ...

Get scikit-learn Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.