8000 ENH Speed up sgdclassifier example plot_sgd_early_stopping.py by johgreen · Pull Request #21627 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content

ENH Speed up sgdclassifier example plot_sgd_early_stopping.py #21627

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions examples/linear_model/plot_sgd_early_stopping.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
import numpy as np
import matplotlib.pyplot as plt

from sklearn import linear_model
from sklearn.linear_model import SGDClassifier
from sklearn.datasets import fetch_openml
from sklearn.model_selection import train_test_split
from sklearn.utils._testing import ignore_warnings
Expand Down Expand Up @@ -89,17 +89,15 @@ def fit_and_score(estimator, max_iter, X_train, X_test, y_train, y_test):

# Define the estimators to compare
estimator_dict = {
"No stopping criterion": linear_model.SGDClassifier(n_iter_no_change=3),
"Training loss": linear_model.SGDClassifier(
early_stopping=False, n_iter_no_change=3, tol=0.1
),
"Validation score": linear_model.SGDClassifier(
"No stopping criterion": SGDClassifier(n_iter_no_change=3),
"Training loss": SGDClassifier(early_stopping=False, n_iter_no_change=3, tol=0.1),
"Validation score": SGDClassifier(
early_stopping=True, n_iter_no_change=3, tol=0.0001, validation_fraction=0.2
),
}

# Load the dataset
X, y = load_mnist(n_samples=10000)
X, y = load_mnist(n_samples=5000)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.5, random_state=0)

results = []
Expand Down
0