Utils¶
IngeoML.utils API¶
- class Batches[source]¶
Helper class to create a set of batches.
- Parameters:
size (int) – Bath size, default=64
strategy (str) – Procedure to create the batch, default=stratified
remainder (str) – Method used to deal with the remainder, default=fill
shuffle (bool) – Whether to shuffle the dataset, default=True
random_state – Random State, default=None
>>> import numpy as np >>> from IngeoML.utils import Batches >>> b = Batches(size=3) >>> X = np.empty((5, 4)) >>> b.split(X) array([[4, 0, 2], [1, 3, 4]]) >>> y = np.r_[0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2] >>> b.split(y=y) array([[ 0, 10, 5], [ 1, 6, 10], [ 2, 10, 7], [ 3, 10, 8], [10, 9, 4]])
- __init__(size: int = 64, strategy: str = 'stratified', remainder: str = 'fill', shuffle: bool = True, random_state: int = None) None[source]¶
- blocks(index: ndarray, rows: int, columns: int)[source]¶
Create the blocks :param index: :type index: np.ndarray :param rows: Number of rows :type rows: int :param columns: Number of columns :type columns: int
>>> from IngeoML.utils import Batches >>> b = Batches(size=3) >>> b.blocks(np.arange(3), columns=2, rows=3) array([[0, 1], [2, 0], [1, 2]])
- static distribution(y: ndarray, size: int = 64)[source]¶
Distribution
- Parameters:
y (np.ndarray) – Labels
size – Size of the batch
- split(D=None, y: ndarray = None) ndarray[source]¶
Method to create the batches
- Parameters:
D – Dataset
y (np.ndarray) – Labels
- __new__(**kwargs)¶