In [14]:
def plot_grid(parameters_final, X_set):
    x_min, x_max = X_set[0,:].min(), X_set[0,:].max()
    y_min, y_max = X_set[1,:].min(), X_set[1,:].max()

    
    xx, yy = np.meshgrid(np.linspace(x_min, x_max,100),np.linspace(y_min, y_max,100))
    
    G = np.c_[xx.ravel(), yy.ravel()]
    D = G.T
    
    predictions = predict(parameters_final, D)
    predictions = predictions.reshape(10000,)

    #plt.contourf(np.c_[xx.ravel(), yy.ravel()][0], np.c_[xx.ravel(), yy.ravel()][1], D, cmap=plt.cm.Spectral)
    color = {'0':'gray',
             '1':'yellow'}
    predictions_colors = [color[str(int(predictions[i]))] for i in range(len(predictions))]
    
    plt.scatter(D[0,:],D[1,:], c=predictions_colors)
In [15]:
def plot_original_set(X_set, y_label, c_class0, c_class1, title_str):
    
    colors_d = {'0' : c_class0,
                '1' : c_class1}
    
    colors = [colors_d[str(int(y_label[0,i]))] for i in range(y_label.shape[1]) ]
    c = np.array(colors)
    plt.scatter(X_set[0,:], X_set[1,:], color=c)
    plt.xlabel('feature1')
    plt.ylabel('feature2')
    plt.title(title_str)
    plt.axis('equal')
    
In [16]:
def plot_classified(X_set,Y_prediction,c_class0, c_class1, title_str, feature_1_str=''):
    
    # c_class0 is a string, a color for class 0; c_class1 is a string, a color for class 1
    
    colors_d = {'0' : c_class0,
                '1' : c_class1}
    
    colors = [colors_d[str(int(Y_prediction[0,i]))] for i in range(Y_prediction.shape[1]) ]
    c = np.array(colors)
    plt.scatter(X_set[0,:], X_set[1,:], color=c)
    plt.xlabel(feature_1_str)
    plt.title(title_str)
    plt.axis('equal')