Skip to content

Commit eec0b4a

Browse files
committed
Pushing the docs to dev/ for branch: master, commit acb810647233e40839203ac553429e8663169702
1 parent 8d64855 commit eec0b4a

File tree

1,053 files changed

+3275
-3284
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,053 files changed

+3275
-3284
lines changed
-34 Bytes
Binary file not shown.
-31 Bytes
Binary file not shown.

dev/_downloads/plot_mlp_alpha.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
},
2727
"outputs": [],
2828
"source": [
29-
"print(__doc__)\n\n\n# Author: Issam H. Laradji\n# License: BSD 3 clause\n\nimport numpy as np\nfrom matplotlib import pyplot as plt\nfrom matplotlib.colors import ListedColormap\nfrom sklearn.model_selection import train_test_split\nfrom sklearn.preprocessing import StandardScaler\nfrom sklearn.datasets import make_moons, make_circles, make_classification\nfrom sklearn.neural_network import MLPClassifier\n\nh = .02 # step size in the mesh\n\nalphas = np.logspace(-5, 3, 5)\nnames = []\nfor i in alphas:\n names.append('alpha ' + str(i))\n\nclassifiers = []\nfor i in alphas:\n classifiers.append(MLPClassifier(alpha=i, random_state=1))\n\nX, y = make_classification(n_features=2, n_redundant=0, n_informative=2,\n random_state=0, n_clusters_per_class=1)\nrng = np.random.RandomState(2)\nX += 2 * rng.uniform(size=X.shape)\nlinearly_separable = (X, y)\n\ndatasets = [make_moons(noise=0.3, random_state=0),\n make_circles(noise=0.2, factor=0.5, random_state=1),\n linearly_separable]\n\nfigure = plt.figure(figsize=(17, 9))\ni = 1\n# iterate over datasets\nfor X, y in datasets:\n # preprocess dataset, split into training and test part\n X = StandardScaler().fit_transform(X)\n X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=.4)\n\n x_min, x_max = X[:, 0].min() - .5, X[:, 0].max() + .5\n y_min, y_max = X[:, 1].min() - .5, X[:, 1].max() + .5\n xx, yy = np.meshgrid(np.arange(x_min, x_max, h),\n np.arange(y_min, y_max, h))\n\n # just plot the dataset first\n cm = plt.cm.RdBu\n cm_bright = ListedColormap(['#FF0000', '#0000FF'])\n ax = plt.subplot(len(datasets), len(classifiers) + 1, i)\n # Plot the training points\n ax.scatter(X_train[:, 0], X_train[:, 1], c=y_train, cmap=cm_bright)\n # and testing points\n ax.scatter(X_test[:, 0], X_test[:, 1], c=y_test, cmap=cm_bright, alpha=0.6)\n ax.set_xlim(xx.min(), xx.max())\n ax.set_ylim(yy.min(), yy.max())\n ax.set_xticks(())\n ax.set_yticks(())\n i += 1\n\n # iterate over classifiers\n for name, clf in zip(names, classifiers):\n ax = plt.subplot(len(datasets), len(classifiers) + 1, i)\n clf.fit(X_train, y_train)\n score = clf.score(X_test, y_test)\n\n # Plot the decision boundary. For that, we will assign a color to each\n # point in the mesh [x_min, x_max]x[y_min, y_max].\n if hasattr(clf, \"decision_function\"):\n Z = clf.decision_function(np.c_[xx.ravel(), yy.ravel()])\n else:\n Z = clf.predict_proba(np.c_[xx.ravel(), yy.ravel()])[:, 1]\n\n # Put the result into a color plot\n Z = Z.reshape(xx.shape)\n ax.contourf(xx, yy, Z, cmap=cm, alpha=.8)\n\n # Plot also the training points\n ax.scatter(X_train[:, 0], X_train[:, 1], c=y_train, cmap=cm_bright,\n edgecolors='black', s=25)\n # and testing points\n ax.scatter(X_test[:, 0], X_test[:, 1], c=y_test, cmap=cm_bright,\n alpha=0.6, edgecolors='black', s=25)\n\n ax.set_xlim(xx.min(), xx.max())\n ax.set_ylim(yy.min(), yy.max())\n ax.set_xticks(())\n ax.set_yticks(())\n ax.set_title(name)\n ax.text(xx.max() - .3, yy.min() + .3, ('%.2f' % score).lstrip('0'),\n size=15, horizontalalignment='right')\n i += 1\n\nfigure.subplots_adjust(left=.02, right=.98)\nplt.show()"
29+
"print(__doc__)\n\n\n# Author: Issam H. Laradji\n# License: BSD 3 clause\n\nimport numpy as np\nfrom matplotlib import pyplot as plt\nfrom matplotlib.colors import ListedColormap\nfrom sklearn.model_selection import train_test_split\nfrom sklearn.preprocessing import StandardScaler\nfrom sklearn.datasets import make_moons, make_circles, make_classification\nfrom sklearn.neural_network import MLPClassifier\n\nh = .02 # step size in the mesh\n\nalphas = np.logspace(-5, 3, 5)\nnames = ['alpha ' + str(i) for i in alphas]\n\nclassifiers = []\nfor i in alphas:\n classifiers.append(MLPClassifier(alpha=i, random_state=1))\n\nX, y = make_classification(n_features=2, n_redundant=0, n_informative=2,\n random_state=0, n_clusters_per_class=1)\nrng = np.random.RandomState(2)\nX += 2 * rng.uniform(size=X.shape)\nlinearly_separable = (X, y)\n\ndatasets = [make_moons(noise=0.3, random_state=0),\n make_circles(noise=0.2, factor=0.5, random_state=1),\n linearly_separable]\n\nfigure = plt.figure(figsize=(17, 9))\ni = 1\n# iterate over datasets\nfor X, y in datasets:\n # preprocess dataset, split into training and test part\n X = StandardScaler().fit_transform(X)\n X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=.4)\n\n x_min, x_max = X[:, 0].min() - .5, X[:, 0].max() + .5\n y_min, y_max = X[:, 1].min() - .5, X[:, 1].max() + .5\n xx, yy = np.meshgrid(np.arange(x_min, x_max, h),\n np.arange(y_min, y_max, h))\n\n # just plot the dataset first\n cm = plt.cm.RdBu\n cm_bright = ListedColormap(['#FF0000', '#0000FF'])\n ax = plt.subplot(len(datasets), len(classifiers) + 1, i)\n # Plot the training points\n ax.scatter(X_train[:, 0], X_train[:, 1], c=y_train, cmap=cm_bright)\n # and testing points\n ax.scatter(X_test[:, 0], X_test[:, 1], c=y_test, cmap=cm_bright, alpha=0.6)\n ax.set_xlim(xx.min(), xx.max())\n ax.set_ylim(yy.min(), yy.max())\n ax.set_xticks(())\n ax.set_yticks(())\n i += 1\n\n # iterate over classifiers\n for name, clf in zip(names, classifiers):\n ax = plt.subplot(len(datasets), len(classifiers) + 1, i)\n clf.fit(X_train, y_train)\n score = clf.score(X_test, y_test)\n\n # Plot the decision boundary. For that, we will assign a color to each\n # point in the mesh [x_min, x_max]x[y_min, y_max].\n if hasattr(clf, \"decision_function\"):\n Z = clf.decision_function(np.c_[xx.ravel(), yy.ravel()])\n else:\n Z = clf.predict_proba(np.c_[xx.ravel(), yy.ravel()])[:, 1]\n\n # Put the result into a color plot\n Z = Z.reshape(xx.shape)\n ax.contourf(xx, yy, Z, cmap=cm, alpha=.8)\n\n # Plot also the training points\n ax.scatter(X_train[:, 0], X_train[:, 1], c=y_train, cmap=cm_bright,\n edgecolors='black', s=25)\n # and testing points\n ax.scatter(X_test[:, 0], X_test[:, 1], c=y_test, cmap=cm_bright,\n alpha=0.6, edgecolors='black', s=25)\n\n ax.set_xlim(xx.min(), xx.max())\n ax.set_ylim(yy.min(), yy.max())\n ax.set_xticks(())\n ax.set_yticks(())\n ax.set_title(name)\n ax.text(xx.max() - .3, yy.min() + .3, ('%.2f' % score).lstrip('0'),\n size=15, horizontalalignment='right')\n i += 1\n\nfigure.subplots_adjust(left=.02, right=.98)\nplt.show()"
3030
]
3131
}
3232
],

dev/_downloads/plot_mlp_alpha.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,7 @@
3232
h = .02 # step size in the mesh
3333

3434
alphas = np.logspace(-5, 3, 5)
35-
names = []
36-
for i in alphas:
37-
names.append('alpha ' + str(i))
35+
names = ['alpha ' + str(i) for i in alphas]
3836

3937
classifiers = []
4038
for i in alphas:

dev/_downloads/plot_out_of_core_classification.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
},
8181
"outputs": [],
8282
"source": [
83-
"def plot_accuracy(x, y, x_legend):\n \"\"\"Plot accuracy as a function of x.\"\"\"\n x = np.array(x)\n y = np.array(y)\n plt.title('Classification accuracy as a function of %s' % x_legend)\n plt.xlabel('%s' % x_legend)\n plt.ylabel('Accuracy')\n plt.grid(True)\n plt.plot(x, y)\n\n\nrcParams['legend.fontsize'] = 10\ncls_names = list(sorted(cls_stats.keys()))\n\n# Plot accuracy evolution\nplt.figure()\nfor _, stats in sorted(cls_stats.items()):\n # Plot accuracy evolution with #examples\n accuracy, n_examples = zip(*stats['accuracy_history'])\n plot_accuracy(n_examples, accuracy, \"training examples (#)\")\n ax = plt.gca()\n ax.set_ylim((0.8, 1))\nplt.legend(cls_names, loc='best')\n\nplt.figure()\nfor _, stats in sorted(cls_stats.items()):\n # Plot accuracy evolution with runtime\n accuracy, runtime = zip(*stats['runtime_history'])\n plot_accuracy(runtime, accuracy, 'runtime (s)')\n ax = plt.gca()\n ax.set_ylim((0.8, 1))\nplt.legend(cls_names, loc='best')\n\n# Plot fitting times\nplt.figure()\nfig = plt.gcf()\ncls_runtime = []\nfor cls_name, stats in sorted(cls_stats.items()):\n cls_runtime.append(stats['total_fit_time'])\n\ncls_runtime.append(total_vect_time)\ncls_names.append('Vectorization')\nbar_colors = ['b', 'g', 'r', 'c', 'm', 'y']\n\nax = plt.subplot(111)\nrectangles = plt.bar(range(len(cls_names)), cls_runtime, width=0.5,\n color=bar_colors)\n\nax.set_xticks(np.linspace(0, len(cls_names) - 1, len(cls_names)))\nax.set_xticklabels(cls_names, fontsize=10)\nymax = max(cls_runtime) * 1.2\nax.set_ylim((0, ymax))\nax.set_ylabel('runtime (s)')\nax.set_title('Training Times')\n\n\ndef autolabel(rectangles):\n \"\"\"attach some text vi autolabel on rectangles.\"\"\"\n for rect in rectangles:\n height = rect.get_height()\n ax.text(rect.get_x() + rect.get_width() / 2.,\n 1.05 * height, '%.4f' % height,\n ha='center', va='bottom')\n plt.setp(plt.xticks()[1], rotation=30)\n\n\nautolabel(rectangles)\nplt.tight_layout()\nplt.show()\n\n# Plot prediction times\nplt.figure()\ncls_runtime = []\ncls_names = list(sorted(cls_stats.keys()))\nfor cls_name, stats in sorted(cls_stats.items()):\n cls_runtime.append(stats['prediction_time'])\ncls_runtime.append(parsing_time)\ncls_names.append('Read/Parse\\n+Feat.Extr.')\ncls_runtime.append(vectorizing_time)\ncls_names.append('Hashing\\n+Vect.')\n\nax = plt.subplot(111)\nrectangles = plt.bar(range(len(cls_names)), cls_runtime, width=0.5,\n color=bar_colors)\n\nax.set_xticks(np.linspace(0, len(cls_names) - 1, len(cls_names)))\nax.set_xticklabels(cls_names, fontsize=8)\nplt.setp(plt.xticks()[1], rotation=30)\nymax = max(cls_runtime) * 1.2\nax.set_ylim((0, ymax))\nax.set_ylabel('runtime (s)')\nax.set_title('Prediction Times (%d instances)' % n_test_documents)\nautolabel(rectangles)\nplt.tight_layout()\nplt.show()"
83+
"def plot_accuracy(x, y, x_legend):\n \"\"\"Plot accuracy as a function of x.\"\"\"\n x = np.array(x)\n y = np.array(y)\n plt.title('Classification accuracy as a function of %s' % x_legend)\n plt.xlabel('%s' % x_legend)\n plt.ylabel('Accuracy')\n plt.grid(True)\n plt.plot(x, y)\n\n\nrcParams['legend.fontsize'] = 10\ncls_names = list(sorted(cls_stats.keys()))\n\n# Plot accuracy evolution\nplt.figure()\nfor _, stats in sorted(cls_stats.items()):\n # Plot accuracy evolution with #examples\n accuracy, n_examples = zip(*stats['accuracy_history'])\n plot_accuracy(n_examples, accuracy, \"training examples (#)\")\n ax = plt.gca()\n ax.set_ylim((0.8, 1))\nplt.legend(cls_names, loc='best')\n\nplt.figure()\nfor _, stats in sorted(cls_stats.items()):\n # Plot accuracy evolution with runtime\n accuracy, runtime = zip(*stats['runtime_history'])\n plot_accuracy(runtime, accuracy, 'runtime (s)')\n ax = plt.gca()\n ax.set_ylim((0.8, 1))\nplt.legend(cls_names, loc='best')\n\n# Plot fitting times\nplt.figure()\nfig = plt.gcf()\ncls_runtime = [stats['total_fit_time']\n for cls_name, stats in sorted(cls_stats.items())]\n\ncls_runtime.append(total_vect_time)\ncls_names.append('Vectorization')\nbar_colors = ['b', 'g', 'r', 'c', 'm', 'y']\n\nax = plt.subplot(111)\nrectangles = plt.bar(range(len(cls_names)), cls_runtime, width=0.5,\n color=bar_colors)\n\nax.set_xticks(np.linspace(0, len(cls_names) - 1, len(cls_names)))\nax.set_xticklabels(cls_names, fontsize=10)\nymax = max(cls_runtime) * 1.2\nax.set_ylim((0, ymax))\nax.set_ylabel('runtime (s)')\nax.set_title('Training Times')\n\n\ndef autolabel(rectangles):\n \"\"\"attach some text vi autolabel on rectangles.\"\"\"\n for rect in rectangles:\n height = rect.get_height()\n ax.text(rect.get_x() + rect.get_width() / 2.,\n 1.05 * height, '%.4f' % height,\n ha='center', va='bottom')\n plt.setp(plt.xticks()[1], rotation=30)\n\n\nautolabel(rectangles)\nplt.tight_layout()\nplt.show()\n\n# Plot prediction times\nplt.figure()\ncls_runtime = []\ncls_names = list(sorted(cls_stats.keys()))\nfor cls_name, stats in sorted(cls_stats.items()):\n cls_runtime.append(stats['prediction_time'])\ncls_runtime.append(parsing_time)\ncls_names.append('Read/Parse\\n+Feat.Extr.')\ncls_runtime.append(vectorizing_time)\ncls_names.append('Hashing\\n+Vect.')\n\nax = plt.subplot(111)\nrectangles = plt.bar(range(len(cls_names)), cls_runtime, width=0.5,\n color=bar_colors)\n\nax.set_xticks(np.linspace(0, len(cls_names) - 1, len(cls_names)))\nax.set_xticklabels(cls_names, fontsize=8)\nplt.setp(plt.xticks()[1], rotation=30)\nymax = max(cls_runtime) * 1.2\nax.set_ylim((0, ymax))\nax.set_ylabel('runtime (s)')\nax.set_title('Prediction Times (%d instances)' % n_test_documents)\nautolabel(rectangles)\nplt.tight_layout()\nplt.show()"
8484
]
8585
}
8686
],

dev/_downloads/plot_out_of_core_classification.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -359,9 +359,8 @@ def plot_accuracy(x, y, x_legend):
359359
# Plot fitting times
360360
plt.figure()
361361
fig = plt.gcf()
362-
cls_runtime = []
363-
for cls_name, stats in sorted(cls_stats.items()):
364-
cls_runtime.append(stats['total_fit_time'])
362+
cls_runtime = [stats['total_fit_time']
363+
for cls_name, stats in sorted(cls_stats.items())]
365364

366365
cls_runtime.append(total_vect_time)
367366
cls_names.append('Vectorization')

dev/_downloads/scikit-learn-docs.pdf

-37.5 KB
Binary file not shown.

dev/_images/iris.png

0 Bytes

0 commit comments

Comments
 (0)