NumpyStream#
- class capymoa.stream.NumpyStream[source]#
Bases:
Stream
[_AnyInstance
]A datastream originating from a numpy array.
>>> from capymoa.stream import NumpyStream >>> import numpy as np >>> X = np.array([[1, 2, 3], [4, 5, 6]]) >>> y = np.array([0, 1]) >>> stream: NumpyStream[LabeledInstance] = NumpyStream(X, y, dataset_name="MyDataset") >>> for instance in stream: ... print(instance) LabeledInstance( Schema(MyDataset), x=[1. 2. 3.], y_index=0, y_label='0' ) LabeledInstance( Schema(MyDataset), x=[4. 5. 6.], y_index=1, y_label='1' )
- __init__(
- X: ndarray,
- y: ndarray,
- dataset_name='No_Name',
- feature_names=None,
- target_name=None,
- target_type: str = None,
Construct a NumpyStream object from a numpy array.
- Parameters:
X – Numpy array of shape (n_samples, n_features) with the feature values
y – Numpy array of shape (n_samples,) with the target values
dataset_name – The name to give to the datastream, defaults to “No_Name”
feature_names – The names given to the features, defaults to None
target_name – The name given to target values, defaults to None
target_type – ‘categorical’ or ‘numeric’ target, defaults to None
- next_instance() _AnyInstance [source]#
Return the next instance in the stream.
- Raises:
ValueError – If the machine learning task is neither a regression nor a classification task.
- Returns:
A labeled instances or a regression depending on the schema.