Documentation of 'smile.data.SparseDataset' Java class
SparseDataset
smile.data

Class SparseDataset

  • All Implemented Interfaces:
    java.lang.Iterable<Datum<SparseArray>>


    public class SparseDataset
    extends java.lang.Object
    implements java.lang.Iterable<Datum<SparseArray>>
    List of Lists sparse matrix format. LIL stores one list per row, where each entry stores a column index and value. Typically, these entries are kept sorted by column index for faster lookup. This format is good for incremental matrix construction.

    LIL is typically used to construct the matrix. Once the matrix is constructed, it is typically converted to a format, such as Harwell-Boeing column-compressed sparse matrix format, which is more efficient for matrix operations.

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      Datum<SparseArray> get(int i)
      Returns the element at the specified position in this dataset.
      double get(int i, int j)
      Returns the value at entry (i, j).
      java.lang.String getDescription()
      Returns the detailed dataset description.
      java.lang.String getName()
      Returns the dataset name.
      java.util.Iterator<Datum<SparseArray>> iterator()
      Returns an iterator over the elements in this dataset in proper sequence.
      int length()
      Returns the number of nonzero entries.
      int ncols()
      Returns the number of columns.
      Datum<SparseArray> remove(int i)
      Removes the element at the specified position in this dataset.
      Attribute response()
      Returns the attribute of the response variable.
      void set(int i, double y)
      Set the real-valued response of a datum.
      void set(int i, double y, double weight)
      Set the class label of real-valued response of a datum.
      void set(int i, int y)
      Set the class label of a datum.
      void set(int i, int j, double x)
      Set a nonzero entry into the matrix.
      void setDescription(java.lang.String description)
      Sets the detailed dataset description.
      void setName(java.lang.String name)
      Sets the dataset name.
      int size()
      Returns the size of dataset that is the number of rows.
      double[][] toArray()
      Returns a dense two-dimensional array containing the whole matrix in this dataset in proper sequence.
      double[] toArray(double[] a)
      Returns an array containing the response variable of the elements in this dataset in proper sequence (from first to last element).
      int[] toArray(int[] a)
      Returns an array containing the class labels of the elements in this dataset in proper sequence (from first to last element).
      SparseArray[] toArray(SparseArray[] a)
      Returns an array containing all of the elements in this dataset in proper sequence (from first to last element); the runtime type of the returned array is that of the specified array.
      SparseMatrix toSparseMatrix()
      Convert into Harwell-Boeing column-compressed sparse matrix format.
      void unitize()
      Unitize each row so that L2 norm of x = 1.
      void unitize1()
      Unitize each row so that L1 norm of x is 1.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.lang.Iterable

        forEach, spliterator
    • Constructor Detail

      • SparseDataset

        public SparseDataset()
        Constructor.
      • SparseDataset

        public SparseDataset(java.lang.String name)
        Constructor.
        Parameters:
        name - the name of dataset.
      • SparseDataset

        public SparseDataset(Attribute response)
        Constructor.
        Parameters:
        response - the attribute type of response variable.
      • SparseDataset

        public SparseDataset(java.lang.String name,
                             Attribute response)
        Constructor.
        Parameters:
        name - the name of dataset.
        response - the attribute type of response variable.
      • SparseDataset

        public SparseDataset(int ncols)
        Constructor.
        Parameters:
        ncols - the number of columns in the matrix.
      • SparseDataset

        public SparseDataset(int ncols,
                             Attribute response)
        Constructor.
        Parameters:
        ncols - the number of columns in the matrix.
        response - the attribute type of response variable.
    • Method Detail

      • getName

        public java.lang.String getName()
        Returns the dataset name.
      • setName

        public void setName(java.lang.String name)
        Sets the dataset name.
      • setDescription

        public void setDescription(java.lang.String description)
        Sets the detailed dataset description.
      • getDescription

        public java.lang.String getDescription()
        Returns the detailed dataset description.
      • response

        public Attribute response()
        Returns the attribute of the response variable. null means no response variable in this dataset.
        Returns:
        the attribute of the response variable. null means no response variable in this dataset.
      • size

        public int size()
        Returns the size of dataset that is the number of rows.
      • ncols

        public int ncols()
        Returns the number of columns.
      • length

        public int length()
        Returns the number of nonzero entries.
      • set

        public void set(int i,
                        int y)
        Set the class label of a datum. If the index exceeds the current matrix size, the matrix will resize itself.
        Parameters:
        i - the row index of entry.
        y - the class label or real-valued response of the datum.
      • set

        public void set(int i,
                        double y)
        Set the real-valued response of a datum. If the index exceeds the current matrix size, the matrix will resize itself.
        Parameters:
        i - the row index of entry.
        y - the class label or real-valued response of the datum.
      • set

        public void set(int i,
                        double y,
                        double weight)
        Set the class label of real-valued response of a datum. If the index exceeds the current matrix size, the matrix will resize itself.
        Parameters:
        i - the row index of entry.
        y - the class label or real-valued response of the datum.
        weight - the optional weight of the datum.
      • set

        public void set(int i,
                        int j,
                        double x)
        Set a nonzero entry into the matrix. If the index exceeds the current matrix size, the matrix will resize itself.
        Parameters:
        i - the row index of entry.
        j - the column index of entry.
        x - the value of entry.
      • get

        public Datum<SparseArray> get(int i)
        Returns the element at the specified position in this dataset.
        Parameters:
        i - the index of the element to be returned.
      • get

        public double get(int i,
                          int j)
        Returns the value at entry (i, j).
        Parameters:
        i - the row index.
        j - the column index.
      • remove

        public Datum<SparseArray> remove(int i)
        Removes the element at the specified position in this dataset.
        Parameters:
        i - the index of the element to be removed.
        Returns:
        the element previously at the specified position.
      • unitize

        public void unitize()
        Unitize each row so that L2 norm of x = 1.
      • unitize1

        public void unitize1()
        Unitize each row so that L1 norm of x is 1.
      • toSparseMatrix

        public SparseMatrix toSparseMatrix()
        Convert into Harwell-Boeing column-compressed sparse matrix format.
      • iterator

        public java.util.Iterator<Datum<SparseArray>> iterator()
        Returns an iterator over the elements in this dataset in proper sequence.
        Specified by:
        iterator in interface java.lang.Iterable<Datum<SparseArray>>
        Returns:
        an iterator over the elements in this dataset in proper sequence
      • toArray

        public double[][] toArray()
        Returns a dense two-dimensional array containing the whole matrix in this dataset in proper sequence.
        Returns:
        a dense two-dimensional array containing the whole matrix in this dataset in proper sequence.
      • toArray

        public SparseArray[] toArray(SparseArray[] a)
        Returns an array containing all of the elements in this dataset in proper sequence (from first to last element); the runtime type of the returned array is that of the specified array. If the dataset fits in the specified array, it is returned therein. Otherwise, a new array is allocated with the runtime type of the specified array and the size of this dataset.

        If the dataset fits in the specified array with room to spare (i.e., the array has more elements than the dataset), the element in the array immediately following the end of the dataset is set to null.

        Parameters:
        a - the array into which the elements of this dataset are to be stored, if it is big enough; otherwise, a new array of the same runtime type is allocated for this purpose.
        Returns:
        an array containing the elements of this dataset.
      • toArray

        public int[] toArray(int[] a)
        Returns an array containing the class labels of the elements in this dataset in proper sequence (from first to last element). Unknown labels will be saved as Integer.MIN_VALUE. If the dataset fits in the specified array, it is returned therein. Otherwise, a new array is allocated with the size of this dataset.

        If the dataset fits in the specified array with room to spare (i.e., the array has more elements than the dataset), the element in the array immediately following the end of the dataset is set to Integer.MIN_VALUE.

        Parameters:
        a - the array into which the class labels of this dataset are to be stored, if it is big enough; otherwise, a new array is allocated for this purpose.
        Returns:
        an array containing the class labels of this dataset.
      • toArray

        public double[] toArray(double[] a)
        Returns an array containing the response variable of the elements in this dataset in proper sequence (from first to last element). If the dataset fits in the specified array, it is returned therein. Otherwise, a new array is allocated with the size of this dataset.

        If the dataset fits in the specified array with room to spare (i.e., the array has more elements than the dataset), the element in the array immediately following the end of the dataset is set to Double.NaN.

        Parameters:
        a - the array into which the response variable of this dataset are to be stored, if it is big enough; otherwise, a new array is allocated for this purpose.
        Returns:
        an array containing the response variable of this dataset.

DataMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.