logo
Loading...

出現 TypeError: __init__() got an unexpected keyword argument 'tol' - Cupoy

Day_49_Blending_HW 和 Day_049_Blending 出現以下Error,請問...

ml100-3,ml100-3-d49

出現 TypeError: __init__() got an unexpected keyword argument 'tol'

2019/10/18 上午 10:59
機器學習共學討論版
William Mok
觀看數:133
回答數:2
收藏數:0
ml100-3
ml100-3-d49

Day_49_Blending_HW 和 Day_049_Blending 出現以下Error,請問如何處理?

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-11-244b28c8e1bf> in <module>()
     12 lr = LogisticRegression(tol=0.001, penalty='l2', fit_intercept=True, C=1.0)
     13 gdbt = GradientBoostingClassifier(tol=100, subsample=0.75, n_estimators=250, max_features=20,
---> 14                                   max_depth=6, learning_rate=0.03)
     15 rf = RandomForestClassifier(n_estimators=100, min_samples_split=2, min_samples_leaf=1, 
     16                             max_features='sqrt', max_depth=6, bootstrap=True)

TypeError: __init__() got an unexpected keyword argument 'tol'

回答列表

  • 2019/10/18 上午 11:29
    陳明佑 (Ming You Chen)
    贊同數:1
    不贊同數:0
    留言數:0

    GradientBoostingClassifier  中, tol 是 sklearn 是 0.20 以後才加入的變數

    所以很有可能你的 sklearn 是比較早的版本


    可以使用下列兩行程式檢查版本

    import sklearn
    sklearn.__version__



    如果確定版本較舊, 如果是 Anaconda 就用內建的 Navigator 更新或 conda 更新

    如果是指令環境下, 直接用 pip upgrade sklearn 之類的指令更新

  • 2019/10/18 下午 00:06
    張維元 (WeiYuan)
    贊同數:1
    不贊同數:0
    留言數:2

    更新指令這樣才對:


    ```

    pip install --upgrade scikit-learn

    # 或

    pip install -U scikit-learn

    ```