DOC Increase execution speed of plot_sgd_comparison
==================================
Comparing various online solvers
==================================
-
An example showing how different online solvers perform
on the hand-written digits dataset.
-
"""
# Author: Rob Zinkov <rob at zinkov dot com>
@@ -21,22 +19,28 @@ from sklearn.linear_model import PassiveAggressiveClassifier
from sklearn.linear_model import LogisticRegression
heldout = [0.95, 0.90, 0.75, 0.50, 0.01]
-rounds = 20
+# Number of rounds to fit and evaluate an estimator.
+rounds = 10
X, y = datasets.load_digits(return_X_y=True)
classifiers = [
- ("SGD", SGDClassifier(max_iter=100)),
- ("ASGD", SGDClassifier(average=True)),
- ("Perceptron", Perceptron()),
+ ("SGD", SGDClassifier(max_iter=110)),
+ ("ASGD", SGDClassifier(max_iter=110, average=True)),
+ ("Perceptron", Perceptron(max_iter=110)),
(
"Passive-Aggressive I",
- PassiveAggressiveClassifier(loss="hinge", C=1.0, tol=1e-4),
+ PassiveAggressiveClassifier(max_iter=110, loss="hinge", C=1.0, tol=1e-4),
),
(
"Passive-Aggressive II",
- PassiveAggressiveClassifier(loss="squared_hinge", C=1.0, tol=1e-4),
+ PassiveAggressiveClassifier(
+ max_iter=110, loss="squared_hinge", C=1.0, tol=1e-4
+ ),
+ ),
+ (
+ "SAG",
+ LogisticRegression(max_iter=110, solver="sag", tol=1e-1, C=1.0e4 / X.shape[0]),
),
- ("SAG", LogisticRegression(solver="sag", tol=1e-1, C=1.0e4 / X.shape[0])),
]
xx = 1.0 - np.array(heldout)
