@@ -0,0 +1,1490 @@
+#!/usr/bin/python%0A%0Aimport numpy as np%0Aimport sklearn%0Aimport matplotlib.pyplot as plt%0Aimport sklearn.datasets%0Aimport sklearn.linear_model%0A%0A######################%0A## Helper Functions ##%0A######################%0A%0Adef plot_decision_boundary(pred_func):%0A    # Set min and max values and give it some padding%0A    x_min, x_max = X%5B:, 0%5D.min() - .5, X%5B:, 0%5D.max() + .5%0A    y_min, y_max = X%5B:, 1%5D.min() - .5, X%5B:, 1%5D.max() + .5%0A    h = 0.01%0A    # Generate a grid of points with distance h between them%0A    xx, yy = np.meshgrid(np.arange(x_min, x_max, h), np.arange(y_min, y_max, h))%0A    # Predict the function value for the whole gid%0A    Z = pred_func(np.c_%5Bxx.ravel(), yy.ravel()%5D)%0A    Z = Z.reshape(xx.shape)%0A    # Plot the contour and training examples%0A    plt.contourf(xx, yy, Z, cmap=plt.cm.Spectral)%0A    plt.scatter(X%5B:, 0%5D, X%5B:, 1%5D, c=y, cmap=plt.cm.Spectral)%0A%0A#######################################%0A## 01-generate a dataset and plot it ##%0A#######################################%0A%0Anp.random.seed(0)%0AX, y = sklearn.datasets.make_moons(200, noise=0.20)%0Aplt.scatter(X%5B:,0%5D,X%5B:,1%5D, s=40, c=y, cmap=plt.cm.Spectral)%0A%0A%0A%0A##################################################%0A## 02-Set up the Logistic Regression classifier ##%0A##################################################%0A%0A# training logistic-reg classifier%0Aclf = sklearn.linear_model.LogisticRegressionCV()%0Aclf.fit(X,y)%0A%0A%0A# Plotting decision boundary%0Aplot_decision_boundary(lambda x: clf.predict(x))%0Aplt.title(%22Logistic Regression%22)%0A%0A%0Aplt.show()%0A%0A

add logistic regresson w/learned decision boundary