Class DemoLabelDataSource

java.lang.Object
org.tribuo.classification.example.DemoLabelDataSource
All Implemented Interfaces:
com.oracle.labs.mlrg.olcut.config.Configurable, com.oracle.labs.mlrg.olcut.provenance.Provenancable<DataSourceProvenance>, Iterable<Example<Label>>, ConfigurableDataSource<Label>, DataSource<Label>
Direct Known Subclasses:
CheckerboardDataSource, ConcentricCirclesDataSource, GaussianLabelDataSource, InterlockingCrescentsDataSource, NoisyInterlockingCrescentsDataSource

public abstract class DemoLabelDataSource extends Object implements ConfigurableDataSource<Label>
The base class for the 2d binary classification data sources in org.tribuo.classification.example.

The feature names are X1 and X2 and the labels are FIRST_CLASS and SECOND_CLASS.

Likely to be sealed to the classes in this package when we adopt Java 17.

  • Field Details

    • factory

      protected static final LabelFactory factory
    • X1

      public static final String X1
      The first feature name.
      See Also:
    • X2

      public static final String X2
      The second feature name.
      See Also:
    • FIRST_CLASS

      public static final Label FIRST_CLASS
      The first class.
    • SECOND_CLASS

      public static final Label SECOND_CLASS
      The second class.
    • numSamples

      @Config(mandatory=true, description="Number of samples to generate.") protected int numSamples
    • seed

      @Config(mandatory=true, description="RNG seed.") protected long seed
    • rng

      protected Random rng
    • examples

      protected List<Example<Label>> examples
  • Method Details

    • postConfig

      public void postConfig()
      Configures the class. Should be called in sub-classes' postConfigs after they've validated their parameters.
      Specified by:
      postConfig in interface com.oracle.labs.mlrg.olcut.config.Configurable
    • generate

      protected abstract List<Example<Label>> generate()
      Generates the examples using the configured fields.

      Is called internally by postConfig().

      Returns:
      The generated examples.
    • getOutputFactory

      public LabelFactory getOutputFactory()
      Description copied from interface: DataSource
      Returns the OutputFactory associated with this Output subclass.
      Specified by:
      getOutputFactory in interface DataSource<Label>
      Returns:
      The output factory.
    • getProvenance

      public DataSourceProvenance getProvenance()
      Specified by:
      getProvenance in interface com.oracle.labs.mlrg.olcut.provenance.Provenancable<DataSourceProvenance>
    • iterator

      public Iterator<Example<Label>> iterator()
      Specified by:
      iterator in interface Iterable<Example<Label>>