java.lang.Object
org.elasticsearch.xpack.core.ml.inference.preprocessing.TargetMeanEncoding
All Implemented Interfaces:
org.apache.lucene.util.Accountable, NamedWriteable, Writeable, org.elasticsearch.xcontent.ToXContent, org.elasticsearch.xcontent.ToXContentObject, LenientlyParsedPreProcessor, PreProcessor, StrictlyParsedPreProcessor, NamedXContentObject

public class TargetMeanEncoding extends Object implements LenientlyParsedPreProcessor, StrictlyParsedPreProcessor
PreProcessor for target mean encoding a set of categorical values for a given field.
  • Field Details

    • SHALLOW_SIZE

      public static final long SHALLOW_SIZE
    • NAME

      public static final org.elasticsearch.xcontent.ParseField NAME
    • FIELD

      public static final org.elasticsearch.xcontent.ParseField FIELD
    • FEATURE_NAME

      public static final org.elasticsearch.xcontent.ParseField FEATURE_NAME
    • TARGET_MAP

      public static final org.elasticsearch.xcontent.ParseField TARGET_MAP
    • DEFAULT_VALUE

      public static final org.elasticsearch.xcontent.ParseField DEFAULT_VALUE
    • CUSTOM

      public static final org.elasticsearch.xcontent.ParseField CUSTOM
  • Constructor Details

  • Method Details

    • fromXContentStrict

      public static TargetMeanEncoding fromXContentStrict(org.elasticsearch.xcontent.XContentParser parser, PreProcessor.PreProcessorParseContext context)
    • fromXContentLenient

      public static TargetMeanEncoding fromXContentLenient(org.elasticsearch.xcontent.XContentParser parser, PreProcessor.PreProcessorParseContext context)
    • getField

      public String getField()
      Returns:
      Field name on which to target mean encode
    • getMeanMap

      public Map<String,Double> getMeanMap()
      Returns:
      Map of Value: targetMean for the target mean encoding
    • getDefaultValue

      public Double getDefaultValue()
      Returns:
      The default value to set when a previously unobserved value is seen
    • getFeatureName

      public String getFeatureName()
      Returns:
      The feature name for the encoded value
    • reverseLookup

      public Map<String,String> reverseLookup()
      Specified by:
      reverseLookup in interface PreProcessor
      Returns:
      Reverse lookup map to match resulting features to their original feature name
    • isCustom

      public boolean isCustom()
      Specified by:
      isCustom in interface PreProcessor
      Returns:
      Is the pre-processor a custom one provided by the user, or automatically created? This changes how feature importance is calculated, as fields generated by custom processors get individual feature importance calculations.
    • getOutputFieldType

      public String getOutputFieldType(String outputField)
      Specified by:
      getOutputFieldType in interface PreProcessor
    • getName

      public String getName()
      Specified by:
      getName in interface NamedXContentObject
      Returns:
      The name of the XContentObject that is to be serialized
    • inputFields

      public List<String> inputFields()
      Description copied from interface: PreProcessor
      The expected input fields
      Specified by:
      inputFields in interface PreProcessor
    • outputFields

      public List<String> outputFields()
      Specified by:
      outputFields in interface PreProcessor
      Returns:
      The resulting output fields. It is imperative that the order is consistent between calls.
    • process

      public void process(Map<String,Object> fields)
      Description copied from interface: PreProcessor
      Process the given fields and their values and return the modified map. NOTE: The passed map object is mutated directly
      Specified by:
      process in interface PreProcessor
      Parameters:
      fields - The fields and their values to process
    • getWriteableName

      public String getWriteableName()
      Specified by:
      getWriteableName in interface NamedWriteable
    • writeTo

      public void writeTo(StreamOutput out) throws IOException
      Specified by:
      writeTo in interface Writeable
      Throws:
      IOException
    • toXContent

      public org.elasticsearch.xcontent.XContentBuilder toXContent(org.elasticsearch.xcontent.XContentBuilder builder, org.elasticsearch.xcontent.ToXContent.Params params) throws IOException
      Specified by:
      toXContent in interface org.elasticsearch.xcontent.ToXContent
      Throws:
      IOException
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • ramBytesUsed

      public long ramBytesUsed()
      Specified by:
      ramBytesUsed in interface org.apache.lucene.util.Accountable
    • toString

      public String toString()
      Overrides:
      toString in class Object