public class Word2VecModel extends Model<Word2VecModel> implements MLWritable
Word2Vec
.Modifier and Type | Class and Description |
---|---|
static class |
Word2VecModel.Word2VecModelWriter$ |
Modifier and Type | Method and Description |
---|---|
static Params |
clear(Param<?> param) |
Word2VecModel |
copy(ParamMap extra)
Creates a copy of this instance with the same UID and some extra params.
|
static String |
explainParam(Param<?> param) |
static String |
explainParams() |
static ParamMap |
extractParamMap() |
static ParamMap |
extractParamMap(ParamMap extra) |
Dataset<Row> |
findSynonyms(String word,
int num)
Find "num" number of words closest in similarity to the given word, not
including the word itself.
|
Dataset<Row> |
findSynonyms(Vector vec,
int num)
Find "num" number of words whose vector representation is most similar to the supplied vector.
|
scala.Tuple2<String,Object>[] |
findSynonymsArray(String word,
int num)
Find "num" number of words closest in similarity to the given word, not
including the word itself.
|
scala.Tuple2<String,Object>[] |
findSynonymsArray(Vector vec,
int num)
Find "num" number of words whose vector representation is most similar to the supplied vector.
|
static <T> scala.Option<T> |
get(Param<T> param) |
static <T> scala.Option<T> |
getDefault(Param<T> param) |
static String |
getInputCol() |
static int |
getMaxIter() |
static int |
getMaxSentenceLength() |
int |
getMaxSentenceLength() |
static int |
getMinCount() |
int |
getMinCount() |
static int |
getNumPartitions() |
int |
getNumPartitions() |
static <T> T |
getOrDefault(Param<T> param) |
static String |
getOutputCol() |
static Param<Object> |
getParam(String paramName) |
static long |
getSeed() |
static double |
getStepSize() |
Dataset<Row> |
getVectors()
Returns a dataframe with two fields, "word" and "vector", with "word" being a String and
and the vector the DenseVector that it is mapped to.
|
static int |
getVectorSize() |
int |
getVectorSize() |
static int |
getWindowSize() |
int |
getWindowSize() |
static <T> boolean |
hasDefault(Param<T> param) |
static boolean |
hasParam(String paramName) |
static boolean |
hasParent() |
static Param<String> |
inputCol() |
static boolean |
isDefined(Param<?> param) |
static boolean |
isSet(Param<?> param) |
static Word2VecModel |
load(String path) |
static IntParam |
maxIter() |
static IntParam |
maxSentenceLength() |
IntParam |
maxSentenceLength()
Sets the maximum length (in words) of each sentence in the input data.
|
static IntParam |
minCount() |
IntParam |
minCount()
The minimum number of times a token must appear to be included in the word2vec model's
vocabulary.
|
static IntParam |
numPartitions() |
IntParam |
numPartitions()
Number of partitions for sentences of words.
|
static Param<String> |
outputCol() |
static Param<?>[] |
params() |
static void |
parent_$eq(Estimator<M> x$1) |
static Estimator<M> |
parent() |
static MLReader<Word2VecModel> |
read() |
static void |
save(String path) |
static LongParam |
seed() |
static <T> Params |
set(Param<T> param,
T value) |
Word2VecModel |
setInputCol(String value) |
Word2VecModel |
setOutputCol(String value) |
static M |
setParent(Estimator<M> parent) |
static DoubleParam |
stepSize() |
static String |
toString() |
Dataset<Row> |
transform(Dataset<?> dataset)
Transform a sentence column to a vector column to represent the whole sentence.
|
StructType |
transformSchema(StructType schema)
:: DeveloperApi ::
|
String |
uid()
An immutable unique ID for the object and its derivatives.
|
StructType |
validateAndTransformSchema(StructType schema)
Validate and transform the input schema.
|
static IntParam |
vectorSize() |
IntParam |
vectorSize()
The dimension of the code that you want to transform from words.
|
static IntParam |
windowSize() |
IntParam |
windowSize()
The window size (context words from [-window, window]).
|
MLWriter |
write()
Returns an
MLWriter instance for this ML instance. |
transform, transform, transform
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getInputCol, inputCol
getOutputCol, outputCol
getMaxIter, maxIter
getStepSize, stepSize
clear, copyValues, defaultCopy, defaultParamMap, explainParam, explainParams, extractParamMap, extractParamMap, get, getDefault, getOrDefault, getParam, hasDefault, hasParam, isDefined, isSet, paramMap, params, set, set, set, setDefault, setDefault, shouldOwn
toString
save
initializeLogging, initializeLogIfNecessary, initializeLogIfNecessary, isTraceEnabled, log_, log, logDebug, logDebug, logError, logError, logInfo, logInfo, logName, logTrace, logTrace, logWarning, logWarning
public static MLReader<Word2VecModel> read()
public static Word2VecModel load(String path)
public static String toString()
public static Param<?>[] params()
public static String explainParam(Param<?> param)
public static String explainParams()
public static final boolean isSet(Param<?> param)
public static final boolean isDefined(Param<?> param)
public static boolean hasParam(String paramName)
public static Param<Object> getParam(String paramName)
public static final <T> scala.Option<T> get(Param<T> param)
public static final <T> T getOrDefault(Param<T> param)
public static final <T> scala.Option<T> getDefault(Param<T> param)
public static final <T> boolean hasDefault(Param<T> param)
public static final ParamMap extractParamMap()
public static Estimator<M> parent()
public static void parent_$eq(Estimator<M> x$1)
public static M setParent(Estimator<M> parent)
public static boolean hasParent()
public static final Param<String> inputCol()
public static final String getInputCol()
public static final Param<String> outputCol()
public static final String getOutputCol()
public static final IntParam maxIter()
public static final int getMaxIter()
public static DoubleParam stepSize()
public static final double getStepSize()
public static final LongParam seed()
public static final long getSeed()
public static final IntParam vectorSize()
public static int getVectorSize()
public static final IntParam windowSize()
public static int getWindowSize()
public static final IntParam numPartitions()
public static int getNumPartitions()
public static final IntParam minCount()
public static int getMinCount()
public static final IntParam maxSentenceLength()
public static int getMaxSentenceLength()
public static void save(String path) throws java.io.IOException
java.io.IOException
public String uid()
Identifiable
uid
in interface Identifiable
public Dataset<Row> getVectors()
public Dataset<Row> findSynonyms(String word, int num)
word
- (undocumented)num
- (undocumented)public Dataset<Row> findSynonyms(Vector vec, int num)
vec
- (undocumented)num
- (undocumented)public scala.Tuple2<String,Object>[] findSynonymsArray(Vector vec, int num)
vec
- (undocumented)num
- (undocumented)public scala.Tuple2<String,Object>[] findSynonymsArray(String word, int num)
word
- (undocumented)num
- (undocumented)public Word2VecModel setInputCol(String value)
public Word2VecModel setOutputCol(String value)
public Dataset<Row> transform(Dataset<?> dataset)
transform
in class Transformer
dataset
- (undocumented)public StructType transformSchema(StructType schema)
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.
transformSchema
in class PipelineStage
schema
- (undocumented)public Word2VecModel copy(ParamMap extra)
Params
defaultCopy()
.copy
in interface Params
copy
in class Model<Word2VecModel>
extra
- (undocumented)public MLWriter write()
MLWritable
MLWriter
instance for this ML instance.write
in interface MLWritable
public int getMaxSentenceLength()
public int getMinCount()
public int getNumPartitions()
public int getVectorSize()
public int getWindowSize()
public IntParam maxSentenceLength()
maxSentenceLength
size.
Default: 1000public IntParam minCount()
public IntParam numPartitions()
public StructType validateAndTransformSchema(StructType schema)
schema
- (undocumented)public IntParam vectorSize()
public IntParam windowSize()