July 2017
Intermediate to advanced
382 pages
9h 13m
English
Similarly, we can also visualize probabilities. For this, we slightly modify the plot function from the previous example. We start out by creating a mesh grid between (x_min, x_max) and (y_min, y_max):
In [18]: def plot_proba(model, X_test, y_test):... # create a mesh to plot in... h = 0.02 # step size in mesh... x_min, x_max = X_test[:, 0].min() - 1, X_test[:, 0].max() + 1... y_min, y_max = X_test[:, 1].min() - 1, X_test[:, 1].max() + 1... xx, yy = np.meshgrid(np.arange(x_min, x_max, h),... np.arange(y_min, y_max, h))
Then we flatten xx and yy and add them column-wise to the feature matrix X_hypo:
... X_hypo = np.column_stack((xx.ravel().astype(np.float32),... yy.ravel().astype(np.float32)))
If we ...
Read now
Unlock full access