iter_arrayΒΆ
Iterates over the rows from an array of features and an array of targets.
This method is intended to work with numpy arrays, but should also work with Python lists.
ParametersΒΆ
-
X (numpy.ndarray)
A 2D array of features.
-
y (numpy.ndarray) β defaults to
NoneAn optional array of targets.
-
feature_names (List[Hashable]) β defaults to
NoneAn optional list of feature names. The features will be labeled with integers if no names are provided.
-
target_names (List[Hashable]) β defaults to
NoneAn optional list of output names. The outputs will be labeled with integers if no names are provided. Only applies if there are multiple outputs, i.e. if
yis a 2D array. -
shuffle (bool) β defaults to
FalseIndicates whether or not to shuffle the input arrays before iterating over them.
-
seed (int) β defaults to
NoneRandom seed used for shuffling the data.
ExamplesΒΆ
>>> from river import stream
>>> import numpy as np
>>> X = np.array([[1, 2, 3], [11, 12, 13]])
>>> Y = np.array([True, False])
>>> dataset = stream.iter_array(
... X, Y,
... feature_names=['x1', 'x2', 'x3']
... )
>>> for x, y in dataset:
... print(x, y)
{'x1': 1, 'x2': 2, 'x3': 3} True
{'x1': 11, 'x2': 12, 'x3': 13} False