End-to-End ML Project- Beginner friendly

50 / 94

Generating Test Set-Indices

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.

INSTRUCTIONS

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.



Note - Having trouble with the assessment engine? Follow the steps listed here

Loading comments...