Class Word2Vec

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

public final class Word2Vec extends Estimator<Word2VecModel> implements Word2VecBase, DefaultParamsWritable
Word2Vec trains a model of Map(String, Vector), i.e. transforms a word into a code for further natural language processing or machine learning process.
See Also:
  • Constructor Details

    • Word2Vec

      public Word2Vec(String uid)
    • Word2Vec

      public Word2Vec()
  • Method Details

    • load

      public static Word2Vec load(String path)
    • read

      public static MLReader<T> read()
    • vectorSize

      public final IntParam vectorSize()
      Description copied from interface: Word2VecBase
      The dimension of the code that you want to transform from words. Default: 100
      Specified by:
      vectorSize in interface Word2VecBase
      Returns:
      (undocumented)
    • windowSize

      public final IntParam windowSize()
      Description copied from interface: Word2VecBase
      The window size (context words from [-window, window]). Default: 5
      Specified by:
      windowSize in interface Word2VecBase
      Returns:
      (undocumented)
    • numPartitions

      public final IntParam numPartitions()
      Description copied from interface: Word2VecBase
      Number of partitions for sentences of words. Default: 1
      Specified by:
      numPartitions in interface Word2VecBase
      Returns:
      (undocumented)
    • minCount

      public final IntParam minCount()
      Description copied from interface: Word2VecBase
      The minimum number of times a token must appear to be included in the word2vec model's vocabulary. Default: 5
      Specified by:
      minCount in interface Word2VecBase
      Returns:
      (undocumented)
    • maxSentenceLength

      public final IntParam maxSentenceLength()
      Description copied from interface: Word2VecBase
      Sets the maximum length (in words) of each sentence in the input data. Any sentence longer than this threshold will be divided into chunks of up to maxSentenceLength size. Default: 1000
      Specified by:
      maxSentenceLength in interface Word2VecBase
      Returns:
      (undocumented)
    • seed

      public final LongParam seed()
      Description copied from interface: HasSeed
      Param for random seed.
      Specified by:
      seed in interface HasSeed
      Returns:
      (undocumented)
    • stepSize

      public DoubleParam stepSize()
      Description copied from interface: HasStepSize
      Param for Step size to be used for each iteration of optimization (&gt; 0).
      Specified by:
      stepSize in interface HasStepSize
      Returns:
      (undocumented)
    • maxIter

      public final IntParam maxIter()
      Description copied from interface: HasMaxIter
      Param for maximum number of iterations (&gt;= 0).
      Specified by:
      maxIter in interface HasMaxIter
      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)
    • 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)
    • setInputCol

      public Word2Vec setInputCol(String value)
    • setOutputCol

      public Word2Vec setOutputCol(String value)
    • setVectorSize

      public Word2Vec setVectorSize(int value)
    • setWindowSize

      public Word2Vec setWindowSize(int value)
    • setStepSize

      public Word2Vec setStepSize(double value)
    • setNumPartitions

      public Word2Vec setNumPartitions(int value)
    • setMaxIter

      public Word2Vec setMaxIter(int value)
    • setSeed

      public Word2Vec setSeed(long value)
    • setMinCount

      public Word2Vec setMinCount(int value)
    • setMaxSentenceLength

      public Word2Vec setMaxSentenceLength(int value)
    • fit

      public Word2VecModel fit(Dataset<?> dataset)
      Description copied from class: Estimator
      Fits a model to the input data.
      Specified by:
      fit in class Estimator<Word2VecModel>
      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 Word2Vec 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<Word2VecModel>
      Parameters:
      extra - (undocumented)
      Returns:
      (undocumented)