Reputation: 41
I am trying to use stratify method in sklearn.model_selection.train_test_split
.
Here is my code:
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)
but I get this error
Invalid parameters passed: {'statify': 386 real....Name: y, Length: 527, dtype: object}
I look for this answer, They mention that stratify splitting
is new in version 0.17 and I have to update my sklearn
.
I looked for the version of mine. It is 0.20.2
scikit-learn 0.20.2 pypi_0 pypi
So please anyone can help me.
Upvotes: 1
Views: 2234
Reputation: 1
This error is due to the typo 'statify' , please change it to 'stratify' it will work. Do check this link sklearn
`
Upvotes: 0
Reputation: 4221
The error you have indicates the parameter statify
does not exist for this function. No wonder... because there is a typo ;-) it should be stratify
instead, and this should work with your version of scikit-learn
.
Upvotes: 2