Class DoubleFieldProcessor

java.lang.Object
org.tribuo.data.columnar.processors.field.DoubleFieldProcessor
All Implemented Interfaces:
com.oracle.labs.mlrg.olcut.config.Configurable, com.oracle.labs.mlrg.olcut.provenance.Provenancable<com.oracle.labs.mlrg.olcut.provenance.ConfiguredObjectProvenance>, FieldProcessor

public class DoubleFieldProcessor extends Object implements FieldProcessor
Processes a column that contains a real value. The name of the feature will be the name given for the column and the value will be the value in the column. This processor returns all doubles that can be parsed by Double.parseDouble(String) including zeros, and so will emit zero valued features.

Returns an empty list if the value failed to parse or was empty.

  • Constructor Details

    • DoubleFieldProcessor

      public DoubleFieldProcessor(String fieldName)
      Constructs a field processor which extracts a single double valued feature from the specified field name.

      Generates features named "<fieldName>@value" where <fieldName> is the argument to this constructor, and does not throw an exception if the value failed to parse.

      Parameters:
      fieldName - The field name to read.
    • DoubleFieldProcessor

      public DoubleFieldProcessor(String fieldName, boolean onlyFieldName)
      Constructs a field processor which extracts a single double valued feature from the specified field name.

      Generates features named "<fieldName>@value" where <fieldName> is the argument to this constructor if onlyFieldName is false, otherwise generates features named "<fieldName>". Does not throw an exception if the value failed to parse.

      Parameters:
      fieldName - The field name to read.
      onlyFieldName - Only use the field name as the feature name.
    • DoubleFieldProcessor

      public DoubleFieldProcessor(String fieldName, boolean onlyFieldName, boolean throwOnInvalid)
      Constructs a field processor which extracts a single double valued feature from the specified field name.

      Generates features named "<fieldName>@value" where <fieldName> is the argument to this constructor if onlyFieldName is false, otherwise generates features named "<fieldName>".

      Parameters:
      fieldName - The field name to read.
      onlyFieldName - Only use the field name as the feature name.
      throwOnInvalid - Throw NumberFormatException if the value failed to parse.
  • Method Details

    • getFieldName

      public String getFieldName()
      Description copied from interface: FieldProcessor
      Gets the field name this FieldProcessor uses.
      Specified by:
      getFieldName in interface FieldProcessor
      Returns:
      The field name.
    • process

      public List<ColumnarFeature> process(String value)
      Description copied from interface: FieldProcessor
      Processes the field value and generates a (possibly empty) list of ColumnarFeatures.
      Specified by:
      process in interface FieldProcessor
      Parameters:
      value - The field value to process.
      Returns:
      A list of ColumnarFeatures.
    • getFeatureType

      public FieldProcessor.GeneratedFeatureType getFeatureType()
      Description copied from interface: FieldProcessor
      Returns the feature type this FieldProcessor generates.
      Specified by:
      getFeatureType in interface FieldProcessor
      Returns:
      The feature type.
    • copy

      public DoubleFieldProcessor copy(String newFieldName)
      Description copied from interface: FieldProcessor
      Returns a copy of this FieldProcessor bound to the supplied newFieldName.
      Specified by:
      copy in interface FieldProcessor
      Parameters:
      newFieldName - The new field name for the copy.
      Returns:
      A copy of this FieldProcessor.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getProvenance

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