Skip to content
Snippets Groups Projects
Data.py 918 B
Newer Older
class Data:
    """
    This class defines the API for Data.
    """

    def __init__(self, x, y):
        """
        Constructor
        Parameters
        ----------
        x : numpy array
            A numpy array of data samples
        y : numpy array
            A numpy array of outputs corresponding to the sample
Rishi Sharma's avatar
Rishi Sharma committed
    def __len__(self):
Rishi Sharma's avatar
Rishi Sharma committed
        """
        Return the number of samples in the dataset

        Returns
        -------
        int
            Number of samples

        """
Rishi Sharma's avatar
Rishi Sharma committed
        return self.y.shape[0]

    def __getitem__(self, i):
        """
        Function to get the item with index i.
        Returns
        -------
        2-tuple
            A tuple of the ith data sample and it's corresponding label