Batch Iterator for Dataset
Data Preparation & Feature Engineering DS practice problem on Onlearn.
Difficulty: easy.
Topics: Understanding Batch Iterator for Dataset, Mini-batch Gradient Descent, NumPy Slicing, Python Generators, Random Shuffling, Memory Mapping, Data Engineering, Numerical Computing, Software Architecture, Statistical Sampling, Memory Management, Data Pipeline Construction, Array Manipulation, Iterator Patterns, Stochastic Processes, Buffer Optimization.
Implement a batch iterable function that samples in a numpy array X and an optional numpy array y. The function should return batches of a specified size. If y is provided, the function should return batches of (X, y) pairs; otherwise, it should return batches of X only.