ageron / ageron/handson-ml

Chapter 3 - sgd_clf failed to converge with scaled data

Offen
#584 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Jupyter Notebook
Sterne
25.6k
Forks
12.7k
PR-Merge-Kennzahlen
PR-Kennzahlen ausstehend

Beschreibung

At the end of the section "Multiclass Classification," there's an example that's supposed to demonstrate improved performance on the stochastic gradient descent classifier when the data is scaled. Whenever I run cross_val_score on this example, it fails to converge. What could be causing this?

```from sklearn.preprocessing import StandardScaler
sgd_clf.random_state_ = 42
sgd_clf.max_iter_ = 8000
scaler = StandardScaler()
X_train_scaled = scaler.fit_transform(X_train.astype(np.float64))
score(sgd_clf, X_train_scaled, y_train, cv=3, scoring="accuracy")
cross_val_score(sgd_clf, X_train_scaled, y_train, cv=3, scoring="accuracy")
/Users/mciul/anaconda3/lib/python3.8/site-packages/sklearn/linear_model/_stochastic_gradient.py:570: ConvergenceWarning: Maximum number of iteration reached before convergence. Consider increasing max_iter to improve the fit.
warnings.warn("Maximum number of iteration reached before "
```
I've been experimenting with changing the initial random state and max iterations, as above. Unless I'm misunderstanding how the classifier works, and setting these values doesn't do anything after initialization?

Any help would be appreciated. I know this isn't exactly the right place to post, but I'm not sure where else to go. Let me know if there is a forum that would be more appropriate.

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.