Skip to content

Commit 61649d2

Browse files
committed
Pushing the docs to dev/ for branch: main, commit c29fe81218833f8f14b28cf6d5374201ac8f3c13
1 parent 4007924 commit 61649d2

File tree

1,223 files changed

+4434
-4419
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,223 files changed

+4434
-4419
lines changed

dev/_downloads/02f111fb3dd79805b161e14c564184fc/plot_sgd_comparison.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"cell_type": "markdown",
1616
"metadata": {},
1717
"source": [
18-
"\n# Comparing various online solvers\n\nAn example showing how different online solvers perform\non the hand-written digits dataset.\n"
18+
"\n# Comparing various online solvers\nAn example showing how different online solvers perform\non the hand-written digits dataset.\n"
1919
]
2020
},
2121
{
@@ -26,7 +26,7 @@
2626
},
2727
"outputs": [],
2828
"source": [
29-
"# Author: Rob Zinkov <rob at zinkov dot com>\n# License: BSD 3 clause\n\nimport numpy as np\nimport matplotlib.pyplot as plt\nfrom sklearn import datasets\n\nfrom sklearn.model_selection import train_test_split\nfrom sklearn.linear_model import SGDClassifier, Perceptron\nfrom sklearn.linear_model import PassiveAggressiveClassifier\nfrom sklearn.linear_model import LogisticRegression\n\nheldout = [0.95, 0.90, 0.75, 0.50, 0.01]\nrounds = 20\nX, y = datasets.load_digits(return_X_y=True)\n\nclassifiers = [\n (\"SGD\", SGDClassifier(max_iter=100)),\n (\"ASGD\", SGDClassifier(average=True)),\n (\"Perceptron\", Perceptron()),\n (\n \"Passive-Aggressive I\",\n PassiveAggressiveClassifier(loss=\"hinge\", C=1.0, tol=1e-4),\n ),\n (\n \"Passive-Aggressive II\",\n PassiveAggressiveClassifier(loss=\"squared_hinge\", C=1.0, tol=1e-4),\n ),\n (\"SAG\", LogisticRegression(solver=\"sag\", tol=1e-1, C=1.0e4 / X.shape[0])),\n]\n\nxx = 1.0 - np.array(heldout)\n\nfor name, clf in classifiers:\n print(\"training %s\" % name)\n rng = np.random.RandomState(42)\n yy = []\n for i in heldout:\n yy_ = []\n for r in range(rounds):\n X_train, X_test, y_train, y_test = train_test_split(\n X, y, test_size=i, random_state=rng\n )\n clf.fit(X_train, y_train)\n y_pred = clf.predict(X_test)\n yy_.append(1 - np.mean(y_pred == y_test))\n yy.append(np.mean(yy_))\n plt.plot(xx, yy, label=name)\n\nplt.legend(loc=\"upper right\")\nplt.xlabel(\"Proportion train\")\nplt.ylabel(\"Test Error Rate\")\nplt.show()"
29+
"# Author: Rob Zinkov <rob at zinkov dot com>\n# License: BSD 3 clause\n\nimport numpy as np\nimport matplotlib.pyplot as plt\nfrom sklearn import datasets\n\nfrom sklearn.model_selection import train_test_split\nfrom sklearn.linear_model import SGDClassifier, Perceptron\nfrom sklearn.linear_model import PassiveAggressiveClassifier\nfrom sklearn.linear_model import LogisticRegression\n\nheldout = [0.95, 0.90, 0.75, 0.50, 0.01]\n# Number of rounds to fit and evaluate an estimator.\nrounds = 10\nX, y = datasets.load_digits(return_X_y=True)\n\nclassifiers = [\n (\"SGD\", SGDClassifier(max_iter=110)),\n (\"ASGD\", SGDClassifier(max_iter=110, average=True)),\n (\"Perceptron\", Perceptron(max_iter=110)),\n (\n \"Passive-Aggressive I\",\n PassiveAggressiveClassifier(max_iter=110, loss=\"hinge\", C=1.0, tol=1e-4),\n ),\n (\n \"Passive-Aggressive II\",\n PassiveAggressiveClassifier(\n max_iter=110, loss=\"squared_hinge\", C=1.0, tol=1e-4\n ),\n ),\n (\n \"SAG\",\n LogisticRegression(max_iter=110, solver=\"sag\", tol=1e-1, C=1.0e4 / X.shape[0]),\n ),\n]\n\nxx = 1.0 - np.array(heldout)\n\nfor name, clf in classifiers:\n print(\"training %s\" % name)\n rng = np.random.RandomState(42)\n yy = []\n for i in heldout:\n yy_ = []\n for r in range(rounds):\n X_train, X_test, y_train, y_test = train_test_split(\n X, y, test_size=i, random_state=rng\n )\n clf.fit(X_train, y_train)\n y_pred = clf.predict(X_test)\n yy_.append(1 - np.mean(y_pred == y_test))\n yy.append(np.mean(yy_))\n plt.plot(xx, yy, label=name)\n\nplt.legend(loc=\"upper right\")\nplt.xlabel(\"Proportion train\")\nplt.ylabel(\"Test Error Rate\")\nplt.show()"
3030
]
3131
}
3232
],
Binary file not shown.

dev/_downloads/333498007f3352f5ce034c50c034c301/plot_sgd_comparison.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@
22
==================================
33
Comparing various online solvers
44
==================================
5-
65
An example showing how different online solvers perform
76
on the hand-written digits dataset.
8-
97
"""
108

119
# Author: Rob Zinkov <rob at zinkov dot com>
@@ -21,22 +19,28 @@
2119
from sklearn.linear_model import LogisticRegression
2220

2321
heldout = [0.95, 0.90, 0.75, 0.50, 0.01]
24-
rounds = 20
22+
# Number of rounds to fit and evaluate an estimator.
23+
rounds = 10
2524
X, y = datasets.load_digits(return_X_y=True)
2625

2726
classifiers = [
28-
("SGD", SGDClassifier(max_iter=100)),
29-
("ASGD", SGDClassifier(average=True)),
30-
("Perceptron", Perceptron()),
27+
("SGD", SGDClassifier(max_iter=110)),
28+
("ASGD", SGDClassifier(max_iter=110, average=True)),
29+
("Perceptron", Perceptron(max_iter=110)),
3130
(
3231
"Passive-Aggressive I",
33-
PassiveAggressiveClassifier(loss="hinge", C=1.0, tol=1e-4),
32+
PassiveAggressiveClassifier(max_iter=110, loss="hinge", C=1.0, tol=1e-4),
3433
),
3534
(
3635
"Passive-Aggressive II",
37-
PassiveAggressiveClassifier(loss="squared_hinge", C=1.0, tol=1e-4),
36+
PassiveAggressiveClassifier(
37+
max_iter=110, loss="squared_hinge", C=1.0, tol=1e-4
38+
),
39+
),
40+
(
41+
"SAG",
42+
LogisticRegression(max_iter=110, solver="sag", tol=1e-1, C=1.0e4 / X.shape[0]),
3843
),
39-
("SAG", LogisticRegression(solver="sag", tol=1e-1, C=1.0e4 / X.shape[0])),
4044
]
4145

4246
xx = 1.0 - np.array(heldout)
Binary file not shown.

dev/_downloads/scikit-learn-docs.zip

81 Bytes
Binary file not shown.
217 Bytes
228 Bytes
242 Bytes
-5 Bytes
173 Bytes

0 commit comments

Comments
 (0)