Class MinHashLSH

All Implemented Interfaces:
Serializable, org.apache.spark.internal.Logging, LSHParams, Params, HasInputCol, HasOutputCol, HasSeed, DefaultParamsWritable, Identifiable, MLWritable, scala.Serializable

public class MinHashLSH extends Estimator<T> implements HasSeed
LSH class for Jaccard distance.

The input can be dense or sparse vectors, but it is more efficient if it is sparse. For example, Vectors.sparse(10, Array((2, 1.0), (3, 1.0), (5, 1.0))) means there are 10 elements in the space. This set contains elements 2, 3, and 5. Also, any input vector must have at least 1 non-zero index, and all non-zero values are treated as binary "1" values.

References: Wikipedia on MinHash

See Also:
  • Constructor Details

    • MinHashLSH

      public MinHashLSH(String uid)
    • MinHashLSH

      public MinHashLSH()
  • Method Details

    • load

      public static MinHashLSH load(String path)
    • read

      public static MLReader<T> read()
    • seed

      public final LongParam seed()
      Description copied from interface: HasSeed
      Param for random seed.
      Specified by:
      seed in interface HasSeed
      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)
    • setInputCol

      public MinHashLSH setInputCol(String value)
    • setOutputCol

      public MinHashLSH setOutputCol(String value)
    • setNumHashTables

      public MinHashLSH setNumHashTables(int value)
    • setSeed

      public MinHashLSH setSeed(long value)
    • 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 MinHashLSH 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 Estimator<MinHashLSHModel>
      Parameters:
      extra - (undocumented)
      Returns:
      (undocumented)
    • fit

      public MinHashLSHModel fit(Dataset<?> dataset)
      Description copied from class: Estimator
      Fits a model to the input data.
      Specified by:
      fit in class Estimator<T extends org.apache.spark.ml.feature.LSHModel<T>>
      Parameters:
      dataset - (undocumented)
      Returns:
      (undocumented)
    • inputCol

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

      public final IntParam numHashTables()
      Description copied from interface: LSHParams
      Param for the number of hash tables used in LSH OR-amplification.

      LSH OR-amplification can be used to reduce the false negative rate. Higher values for this param lead to a reduced false negative rate, at the expense of added computational complexity.

      Specified by:
      numHashTables in interface LSHParams
      Returns:
      (undocumented)
    • outputCol

      public final Param<String> outputCol()
      Description copied from interface: HasOutputCol
      Param for output column name.
      Specified by:
      outputCol in interface HasOutputCol
      Returns:
      (undocumented)