Class VectorSizeHint

All Implemented Interfaces:
Serializable, org.apache.spark.internal.Logging, Params, HasHandleInvalid, HasInputCol, DefaultParamsWritable, Identifiable, MLWritable

public class VectorSizeHint extends Transformer implements HasInputCol, HasHandleInvalid, DefaultParamsWritable
A feature transformer that adds size information to the metadata of a vector column. VectorAssembler needs size information for its input columns and cannot be used on streaming dataframes without this metadata.

Note: VectorSizeHint modifies inputCol to include size metadata and does not have an outputCol.

See Also:
  • Constructor Details

    • VectorSizeHint

      public VectorSizeHint(String uid)
    • VectorSizeHint

      public VectorSizeHint()
  • Method Details

    • load

      public static VectorSizeHint load(String path)
    • read

      public static MLReader<T> read()
    • inputCol

      public final Param<String> inputCol()
      Description copied from interface: HasInputCol
      Param for input column name.
      Specified by:
      inputCol in interface HasInputCol
      Returns:
      (undocumented)
    • uid

      public String uid()
      Description copied from interface: Identifiable
      An immutable unique ID for the object and its derivatives.
      Specified by:
      uid in interface Identifiable
      Returns:
      (undocumented)
    • size

      public IntParam size()
      The size of Vectors in inputCol.
      Returns:
      (undocumented)
    • getSize

      public int getSize()
      group getParam
    • setSize

      public VectorSizeHint setSize(int value)
    • setInputCol

      public VectorSizeHint setInputCol(String value)
    • handleInvalid

      public Param<String> handleInvalid()
      Param for how to handle invalid entries. Invalid vectors include nulls and vectors with the wrong size. The options are skip (filter out rows with invalid vectors), error (throw an error) and optimistic (do not check the vector size, and keep all rows). error by default.

      Note: Users should take care when setting this param to optimistic. The use of the optimistic option will prevent the transformer from validating the sizes of vectors in inputCol. A mismatch between the metadata of a column and its contents could result in unexpected behaviour or errors when using that column.

      Specified by:
      handleInvalid in interface HasHandleInvalid
      Returns:
      (undocumented)
    • setHandleInvalid

      public VectorSizeHint setHandleInvalid(String value)
    • transform

      public Dataset<Row> transform(Dataset<?> dataset)
      Description copied from class: Transformer
      Transforms the input dataset.
      Specified by:
      transform in class Transformer
      Parameters:
      dataset - (undocumented)
      Returns:
      (undocumented)
    • transformSchema

      public StructType transformSchema(StructType schema)
      Description copied from class: PipelineStage
      Check transform validity and derive the output schema from the input schema.

      We check validity for interactions between parameters during transformSchema and raise an exception if any parameter value is invalid. Parameter value checks which do not depend on other parameters are handled by Param.validate().

      Typical implementation should first conduct verification on schema change and parameter validity, including complex parameter interaction checks.

      Specified by:
      transformSchema in class PipelineStage
      Parameters:
      schema - (undocumented)
      Returns:
      (undocumented)
    • copy

      public VectorSizeHint copy(ParamMap extra)
      Description copied from interface: Params
      Creates a copy of this instance with the same UID and some extra params. Subclasses should implement this method and set the return type properly. See defaultCopy().
      Specified by:
      copy in interface Params
      Specified by:
      copy in class Transformer
      Parameters:
      extra - (undocumented)
      Returns:
      (undocumented)
    • toString

      public String toString()
      Specified by:
      toString in interface Identifiable
      Overrides:
      toString in class Object