【问题标题】:error of (Invalid parameters) from stratify method in sklearn.model_selection.train_test_splitsklearn.model_selection.train_test_split 中分层方法的(无效参数)错误
【发布时间】:2019-07-26 17:20:54
【问题描述】:

我正在尝试在sklearn.model_selection.train_test_split 中使用分层方法。 这是我的代码:

x=df["x"]
y=df["y"]
X_train, X_test, Y_train, Y_test = train_test_split( x, y, test_size=0.2, random_state=42,statify= y)

但我收到此错误

Invalid parameters passed: {'statify': 386 real....Name: y, Length: 527, dtype: object}

我正在寻找这个answer,他们提到stratify splitting 是0.17 版中的新内容,我必须更新我的sklearn。 我找了我的版本。是0.20.2

scikit-learn              0.20.2                   pypi_0    pypi

所以请任何人都可以帮助我。

【问题讨论】:

    标签: python scikit-learn train-test-split


    【解决方案1】:

    您遇到的错误表明该函数的参数statify 不存在。难怪......因为有一个错字;-) 它应该是stratify,这应该适用于您的scikit-learn 版本。

    【讨论】:

      【解决方案2】:

      此错误是由于拼写错误 'statify' 造成的,请将其更改为 'stratify' 它将起作用。请检查此链接sklearn

      `

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2014-09-17
        • 2012-07-03
        • 2020-08-21
        • 1970-01-01
        • 2021-09-14
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多