Login using Social Account
     Continue with GoogleLogin using your credentials
Now, as we have created an object of StratifiedShuffleSplit
, let's start generating the test set.
At first, we use the split()
method of the class StratifiedShuffleSplit
. Its syntax is-
obj_name.split(X,y)
where X
is the dataset and y
is an array-like on the basis of which stratification has to be done.
split()
method on the object split_object
.Specify the dataset and stratification array in the arguments. Remember, we have to perform stratification according to the variable income_cat
. split()
method returns a generator object. So, store it in a variable gen_obj
. This generator object contains indexes of instances belonging to the training and testing dataset.Taking you to the next exercise in seconds...
Want to create exercises like this yourself? Click here.
Loading comments...