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

Model fitted by VectorIndexer. Transform categorical features to use 0-based indices instead of their original values. - Categorical features are mapped to indices. - Continuous features (columns) are left unchanged. This also appends metadata to the output column, marking features as Numeric (continuous), Nominal (categorical), or Binary (either continuous or categorical). Non-ML metadata is not carried over from the input to the output column.

This maintains vector sparsity.

param: numFeatures Number of features, i.e., length of Vectors which this transforms param: categoryMaps Feature value index. Keys are categorical feature indices (column indices). Values are maps from original features values to 0-based category indices. If a feature is not in this map, it is treated as continuous.

See Also:
  • Nested Class Summary

    Nested Classes

    Nested classes/interfaces inherited from interface org.apache.spark.internal.Logging

    org.apache.spark.internal.Logging.LogStringContext, org.apache.spark.internal.Logging.SparkShellLoggingFilter

  • Method Summary

    scala.collection.immutable.Map<Object,scala.collection.immutable.Map<Object,Object>>

    Creates a copy of this instance with the same UID and some extra params.

    Param for how to handle invalid data (unseen labels or NULL values).

    inputCol()

    Param for input column name.

    Java-friendly version of categoryMaps()

    Threshold for the number of values a categorical feature can take.

    int

    outputCol()

    Param for output column name.

    read()

    toString()

    Transforms the input dataset.

    Check transform validity and derive the output schema from the input schema.

    uid()

    An immutable unique ID for the object and its derivatives.

    write()

    Returns an MLWriter instance for this ML instance.

    Methods inherited from interface org.apache.spark.internal.Logging

    initializeForcefully, initializeLogIfNecessary, initializeLogIfNecessary, initializeLogIfNecessary$default$2, isTraceEnabled, log, logBasedOnLevel, logDebug, logDebug, logDebug, logDebug, logError, logError, logError, logError, logInfo, logInfo, logInfo, logInfo, logName, LogStringContext, logTrace, logTrace, logTrace, logTrace, logWarning, logWarning, logWarning, logWarning, MDC, org$apache$spark$internal$Logging$$log_, org$apache$spark$internal$Logging$$log__$eq, withLogContext

    Methods inherited from interface org.apache.spark.ml.util.MLWritable

    save

  • Method Details

    • read

    • load

    • handleInvalid

      Param for how to handle invalid data (unseen labels or NULL values). Note: this param only applies to categorical features, not continuous ones. Options are: 'skip': filter out rows with invalid data. 'error': throw an error. 'keep': put invalid data in a special additional bucket, at index of the number of categories of the feature. Default value: "error"

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

      Threshold for the number of values a categorical feature can take. If a feature is found to have > maxCategories values, then it is declared continuous. Must be greater than or equal to 2.

      (default = 20)

      Specified by:
      maxCategories in interface VectorIndexerParams
      Returns:
      (undocumented)
    • outputCol

      Param for output column name.

      Specified by:
      outputCol in interface HasOutputCol
      Returns:
      (undocumented)
    • inputCol

      Description copied from interface: HasInputCol

      Param for input column name.

      Specified by:
      inputCol in interface HasInputCol
      Returns:
      (undocumented)
    • uid

      An immutable unique ID for the object and its derivatives.

      Specified by:
      uid in interface Identifiable
      Returns:
      (undocumented)
    • numFeatures

      public int numFeatures()

    • categoryMaps

      public scala.collection.immutable.Map<Object,scala.collection.immutable.Map<Object,Object>> categoryMaps()

    • javaCategoryMaps

      Java-friendly version of categoryMaps()

    • setInputCol

    • setOutputCol

    • transform

      Transforms the input dataset.

      Specified by:
      transform in class Transformer
      Parameters:
      dataset - (undocumented)
      Returns:
      (undocumented)
    • transformSchema

      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

      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 Model<VectorIndexerModel>
      Parameters:
      extra - (undocumented)
      Returns:
      (undocumented)
    • write

      Description copied from interface: MLWritable

      Returns an MLWriter instance for this ML instance.

      Specified by:
      write in interface MLWritable
      Returns:
      (undocumented)
    • toString

      Specified by:
      toString in interface Identifiable
      Overrides:
      toString in class Object