Skip to content Skip to sidebar Skip to footer

Error: __init__() Got An Unexpected Keyword Argument 'n_splits'

I am going to perform ShuffleSplit() method for California housing dataset (Source: https://www.dcc.fc.up.pt/~ltorgo/Regression/cal_housing.html) to fit SGD regression. However, th

Solution 1:

You are mixing up two different modules.

Before 0.18, cross_validation was used for ShuffleSplit. In that, n_splits was not present. n was used to define the number of splits

But since you have updated to 0.18 now, cross_validation and grid_search has been deprecated in favor of model_selection.

This is mentioned in docs here, and these modules will be removed from version 0.20

So instead of this:

from sklearn.cross_validationimportShuffleSplitfrom sklearn.cross_validationimport train_test_split

Do this:

from sklearn.model_selectionimportShuffleSplit
fro

m sklearn.model_selection import train_test_split

Then you can use n_splits.

cv = ShuffleSplit(n_splits = 10, test_size = 0.2, random_state = 0)

Post a Comment for "Error: __init__() Got An Unexpected Keyword Argument 'n_splits'"