Package ai.djl.basicdataset.tabular
Class CsvDataset.CsvBuilder<T extends CsvDataset.CsvBuilder<T>>
- java.lang.Object
-
- ai.djl.training.dataset.RandomAccessDataset.BaseBuilder<T>
-
- ai.djl.basicdataset.tabular.CsvDataset.CsvBuilder<T>
-
- Direct Known Subclasses:
AirfoilRandomAccess.Builder,AmazonReview.Builder,AmesRandomAccess.Builder
- Enclosing class:
- CsvDataset
public static class CsvDataset.CsvBuilder<T extends CsvDataset.CsvBuilder<T>> extends ai.djl.training.dataset.RandomAccessDataset.BaseBuilder<T>Used to build aCsvDataset.
-
-
Field Summary
Fields Modifier and Type Field Description protected org.apache.commons.csv.CSVFormatcsvFormatprotected java.net.URLcsvUrlprotected java.util.List<CsvDataset.Feature>featuresprotected java.util.List<CsvDataset.Feature>labels
-
Constructor Summary
Constructors Modifier Constructor Description protectedCsvBuilder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TaddCategoricalFeature(java.lang.String name)Adds a categorical feature to the feature set.TaddCategoricalFeature(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.TaddCategoricalLabel(java.lang.String name)Adds a categorical feature to the label set.TaddCategoricalLabel(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.TaddFeature(CsvDataset.Feature... features)Adds the features to the feature set.TaddLabel(CsvDataset.Feature... labels)Adds the features to the label set.TaddNumericFeature(java.lang.String name)Adds a numeric feature to the feature set.TaddNumericLabel(java.lang.String name)Adds a number feature to the label set.CsvDatasetbuild()Builds the newCsvDataset.ToptCsvFile(java.nio.file.Path csvFile)Sets the optional CSV file path.ToptCsvUrl(java.lang.String csvUrl)Sets the optional CSV file URL.protected Tself()TsetCsvFormat(org.apache.commons.csv.CSVFormat csvFormat)Sets the CSV file format.
-
-
-
Field Detail
-
csvUrl
protected java.net.URL csvUrl
-
csvFormat
protected org.apache.commons.csv.CSVFormat csvFormat
-
features
protected java.util.List<CsvDataset.Feature> features
-
labels
protected java.util.List<CsvDataset.Feature> labels
-
-
Method Detail
-
self
protected T self()
- Specified by:
selfin classai.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- theCSVFormat- 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 namemap- a map contains categorical value maps to indexonehotEncode- 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 namemap- a map contains categorical value maps to indexonehotEncode- true if use onehot encode- Returns:
- this builder
-
build
public CsvDataset build()
Builds the newCsvDataset.- Returns:
- the new
CsvDataset
-
-