Enrollments closing soon for Post Graduate Certificate Program in Applied Data Science & AI By IIT Roorkee | 3 Seats Left
Apply NowLogin using Social Account
     Continue with GoogleLogin using your credentials
Now, we need to extract the indices from the generator object. We use the next()
function for it. It returns the next item from any generator or iterator. Its syntax is-
next(object_name)
where object_name
is the generator or iterator object.
So, we use it to get training and testing indices needed to split the dataset. Remember, the generator object contains 2 items, so you may require 2 variables to unpack the object.
Unpack the object gen_obj
and store the output in variables train_ind
and test_ind
which represent training and testing indices.
Note- The first argument must be train_ind
and second must be test_ind
while unpacking.
Taking you to the next exercise in seconds...
Want to create exercises like this yourself? Click here.
Note - Having trouble with the assessment engine? Follow the steps listed here
Loading comments...