天天看點

成功解決FutureWarning: max_iter and tol parameters have been added

解決問題

FutureWarning: max_iter and tol parameters have been added in <class 'sklearn.linear_model.stochastic_gradient.SGDClassifier'> in 0.19. If both are left unset, they default to max_iter=5 and tol=None. If tol is not None, max_iter defaults to max_iter=1000. From 0.21, default max_iter will be 1000, and default tol will be 1e-3.

 "and default tol will be 1e-3." % type(self), FutureWarning)

類似的問題

linear_model\stochastic_gradient.py:128: FutureWarning: max_iter and tol parameters have been added in <class 'sklearn.linear_model.stochastic_gradient.SGDRegressor'> in 0.19. If both are left unset, they default to max_iter=5 and tol=None. If tol is not None, max_iter defaults to max_iter=1000. From 0.21, default max_iter will be 1000, and default tol will be 1e-3.

解決思路

未來警告:在0.19中的<class'sklearn.linear_model.randomatic_gradient.sgdclassifier'>中添加了max_iter和tol參數。如果兩個都未設定,則預設為max_iter=5,tol=none。如果tol不是none,max-iter預設為max-iter=1000。從0.21開始,預設的最大值為1000,預設的公差為1e-3。“預設TOL将為1E-3。

解決方法

此資訊提示為警告,而不是error,即使不處理也不會影響代碼程式設計的運作。如果想要去掉,可以更新庫至最新版本!

然後根據提示修改使用方法!

stochastic_gradient子產品已經被重構,在未來的版本中預設參數有所改變!

然後使用最新版本stochastic_gradient方法,并要知道預設參數已經随着版本更新而改變了。

繼續閱讀