ageron / ageron/handson-ml

Chapter 3 - sgd_clf failed to converge with scaled data

未關閉
#584 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
Jupyter Notebook
星號
25.6k
分支
12.7k
PR 合併指標
PR 指標待擷取

描述

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.

貢獻指南

這個儲存庫沒有索引到貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。