Class RLinkDataSet<T extends VectorExample>

  • All Implemented Interfaces:
    java.lang.Iterable<T>
    Direct Known Subclasses:
    RecPairSet, VectorSet

    public abstract class RLinkDataSet<T extends VectorExample>
    extends java.lang.Object
    implements java.lang.Iterable<T>
    A container for storing a set of training examples suitable for model training. Subclasses can add operations to load from CSV, etc.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.util.List<T> examples
      Stores all examples for this dataset
    • Constructor Summary

      Constructors 
      Constructor Description
      RLinkDataSet​(int nFeatures)
      Creates empty dataset.
      RLinkDataSet​(int nFeatures, int initialCapacity)
      Creates empty dataset.
    • Field Detail

      • examples

        protected final java.util.List<T extends VectorExample> examples
        Stores all examples for this dataset
    • Constructor Detail

      • RLinkDataSet

        public RLinkDataSet​(int nFeatures)
        Creates empty dataset.
        Parameters:
        nFeatures - - number of model features in each example of this dataset
      • RLinkDataSet

        public RLinkDataSet​(int nFeatures,
                            int initialCapacity)
        Creates empty dataset. Use when the number of examples is already known.
        Parameters:
        nFeatures - - number of model features in each example of this dataset
        initialCapacity - - number of examples that will be stored in this dataset
    • Method Detail

      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
        Returns:
        a string with all examples in this dataset.
      • createDataSet

        public abstract RLinkDataSet<T> createDataSet()
        Returns:
        a new empty dataset of the appropriate subclass of RLinkDataSet
      • iterator

        public java.util.Iterator<T> iterator()
        Specified by:
        iterator in interface java.lang.Iterable<T extends VectorExample>
        Returns:
        an iterator over the examples in this dataset
      • add

        public void add​(T e)
        Adds the given example to this dataset.
        Parameters:
        e - - the new training example. Must have matching number of features.
        Throws:
        java.lang.IllegalArgumentException - if number of features in the given example does not match the number of features for this dataset.
      • size

        public int size()
        Returns:
        the number of examples in this dataset.
      • verifyDatasetProportion

        public static void verifyDatasetProportion​(double destProportion)
        Verifies the proportion of validation dataset as a percentage of all examples.
        Throws:
        java.lang.IllegalArgumentException - if destProportion is not in interval [0.0, 1.0)
      • getNFeatures

        public int getNFeatures()
        Returns:
        the number of features in each example in this dataset
      • clearPredictions

        public void clearPredictions()
        Clears stored predictions from all examples.