Class CsvDataset.CsvBuilder<T extends CsvDataset.CsvBuilder<T>>

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected org.apache.commons.csv.CSVFormat csvFormat  
      protected java.net.URL csvUrl  
      protected java.util.List<CsvDataset.Feature> features  
      protected java.util.List<CsvDataset.Feature> labels  
      • Fields inherited from class ai.djl.training.dataset.RandomAccessDataset.BaseBuilder

        dataBatchifier, device, labelBatchifier, limit, pipeline, prefetchNumber, sampler, targetPipeline
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected CsvBuilder()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      T addCategoricalFeature​(java.lang.String name)
      Adds a categorical feature to the feature set.
      T addCategoricalFeature​(java.lang.String name, java.util.Map<java.lang.String,​java.lang.Integer> map, boolean onehotEncode)
      Adds a categorical feature to the feature set with specified mapping.
      T addCategoricalLabel​(java.lang.String name)
      Adds a categorical feature to the label set.
      T addCategoricalLabel​(java.lang.String name, java.util.Map<java.lang.String,​java.lang.Integer> map, boolean onehotEncode)
      Adds a categorical feature to the feature set with specified mapping.
      T addFeature​(CsvDataset.Feature... features)
      Adds the features to the feature set.
      T addLabel​(CsvDataset.Feature... labels)
      Adds the features to the label set.
      T addNumericFeature​(java.lang.String name)
      Adds a numeric feature to the feature set.
      T addNumericLabel​(java.lang.String name)
      Adds a number feature to the label set.
      CsvDataset build()
      Builds the new CsvDataset.
      T optCsvFile​(java.nio.file.Path csvFile)
      Sets the optional CSV file path.
      T optCsvUrl​(java.lang.String csvUrl)
      Sets the optional CSV file URL.
      protected T self()
      T setCsvFormat​(org.apache.commons.csv.CSVFormat csvFormat)
      Sets the CSV file format.
      • Methods inherited from class ai.djl.training.dataset.RandomAccessDataset.BaseBuilder

        addTargetTransform, addTransform, getSampler, optDataBatchifier, optDevice, optLabelBatchifier, optLimit, optPipeline, optPrefetchNumber, optTargetPipeline, setSampling, setSampling, setSampling
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • csvUrl

        protected java.net.URL csvUrl
      • csvFormat

        protected org.apache.commons.csv.CSVFormat csvFormat
    • Constructor Detail

      • CsvBuilder

        protected CsvBuilder()
    • Method Detail

      • self

        protected T self()
        Specified by:
        self in class ai.djl.training.dataset.RandomAccessDataset.BaseBuilder<T extends CsvDataset.CsvBuilder<T>>
      • optCsvFile

        public T optCsvFile​(java.nio.file.Path csvFile)
        Sets the optional CSV file path.
        Parameters:
        csvFile - the CSV file path
        Returns:
        this builder
      • optCsvUrl

        public T optCsvUrl​(java.lang.String csvUrl)
        Sets the optional CSV file URL.
        Parameters:
        csvUrl - the CSV file URL
        Returns:
        this builder
      • setCsvFormat

        public T setCsvFormat​(org.apache.commons.csv.CSVFormat csvFormat)
        Sets the CSV file format.
        Parameters:
        csvFormat - the CSVFormat
        Returns:
        this builder
      • addFeature

        public T addFeature​(CsvDataset.Feature... features)
        Adds the features to the feature set.
        Parameters:
        features - the features
        Returns:
        this builder
      • addNumericFeature

        public T addNumericFeature​(java.lang.String name)
        Adds a numeric feature to the feature set.
        Parameters:
        name - the feature name
        Returns:
        this builder
      • addCategoricalFeature

        public T addCategoricalFeature​(java.lang.String name)
        Adds a categorical feature to the feature set.
        Parameters:
        name - the feature name
        Returns:
        this builder
      • addCategoricalFeature

        public T addCategoricalFeature​(java.lang.String name,
                                       java.util.Map<java.lang.String,​java.lang.Integer> map,
                                       boolean onehotEncode)
        Adds a categorical feature to the feature set with specified mapping.
        Parameters:
        name - the feature name
        map - a map contains categorical value maps to index
        onehotEncode - true if use onehot encode
        Returns:
        this builder
      • addLabel

        public T addLabel​(CsvDataset.Feature... labels)
        Adds the features to the label set.
        Parameters:
        labels - the labels
        Returns:
        this builder
      • addNumericLabel

        public T addNumericLabel​(java.lang.String name)
        Adds a number feature to the label set.
        Parameters:
        name - the label name
        Returns:
        this builder
      • addCategoricalLabel

        public T addCategoricalLabel​(java.lang.String name)
        Adds a categorical feature to the label set.
        Parameters:
        name - the feature name
        Returns:
        this builder
      • addCategoricalLabel

        public T addCategoricalLabel​(java.lang.String name,
                                     java.util.Map<java.lang.String,​java.lang.Integer> map,
                                     boolean onehotEncode)
        Adds a categorical feature to the feature set with specified mapping.
        Parameters:
        name - the feature name
        map - a map contains categorical value maps to index
        onehotEncode - true if use onehot encode
        Returns:
        this builder