public class BucketedRandomProjectionLSHModel extends Model<T> implements BucketedRandomProjectionLSHParams
Model produced by BucketedRandomProjectionLSH, where multiple random vectors are stored. The
vectors are normalized to be unit vectors and each vector is used in a hash function:
h_i(x) = floor(r_i.dot(x) / bucketLength)
where r_i is the i-th random unit vector. The number of buckets will be (max L2 norm of input
vectors) / bucketLength.
param: randUnitVectors An array of random unit vectors. Each vector represents a hash function.
| Modifier and Type | Method and Description |
|---|---|
Dataset<?> |
approxNearestNeighbors(Dataset<?> dataset,
Vector key,
int numNearestNeighbors)
Overloaded method for approxNearestNeighbors.
|
Dataset<?> |
approxNearestNeighbors(Dataset<?> dataset,
Vector key,
int numNearestNeighbors,
String distCol)
Given a large dataset and an item, approximately find at most k items which have the closest
distance to the item.
|
Dataset<?> |
approxSimilarityJoin(Dataset<?> datasetA,
Dataset<?> datasetB,
double threshold)
Overloaded method for approxSimilarityJoin.
|
Dataset<?> |
approxSimilarityJoin(Dataset<?> datasetA,
Dataset<?> datasetB,
double threshold,
String distCol)
Join two datasets to approximately find all pairs of rows whose distance are smaller than
the threshold.
|
BucketedRandomProjectionLSHModel |
copy(ParamMap extra)
Creates a copy of this instance with the same UID and some extra params.
|
static BucketedRandomProjectionLSHModel |
load(String path) |
static MLReader<BucketedRandomProjectionLSHModel> |
read() |
BucketedRandomProjectionLSHModel |
setInputCol(String value) |
BucketedRandomProjectionLSHModel |
setOutputCol(String value) |
Dataset<Row> |
transform(Dataset<?> dataset)
Transforms the input dataset.
|
StructType |
transformSchema(StructType schema)
:: DeveloperApi ::
|
String |
uid()
An immutable unique ID for the object and its derivatives.
|
MLWriter |
write()
Returns an
MLWriter instance for this ML instance. |
transform, transform, transformequals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitbucketLength, getBucketLengthclear, copyValues, defaultCopy, defaultParamMap, explainParam, explainParams, extractParamMap, extractParamMap, get, getDefault, getOrDefault, getParam, hasDefault, hasParam, isDefined, isSet, paramMap, params, set, set, set, setDefault, setDefault, shouldOwntoStringgetNumHashTables, numHashTables, validateAndTransformSchemagetInputCol, inputColgetOutputCol, outputColsaveinitializeLogging, initializeLogIfNecessary, initializeLogIfNecessary, isTraceEnabled, log_, log, logDebug, logDebug, logError, logError, logInfo, logInfo, logName, logTrace, logTrace, logWarning, logWarningpublic static MLReader<BucketedRandomProjectionLSHModel> read()
public static BucketedRandomProjectionLSHModel load(String path)
public String uid()
Identifiableuid in interface Identifiablepublic BucketedRandomProjectionLSHModel setInputCol(String value)
public BucketedRandomProjectionLSHModel setOutputCol(String value)
public BucketedRandomProjectionLSHModel copy(ParamMap extra)
ParamsdefaultCopy().copy in interface Paramscopy in class Model<BucketedRandomProjectionLSHModel>extra - (undocumented)public MLWriter write()
MLWritableMLWriter instance for this ML instance.write in interface MLWritablepublic Dataset<?> approxNearestNeighbors(Dataset<?> dataset, Vector key, int numNearestNeighbors, String distCol)
outputCol is missing, the method will transform the data; if
the outputCol exists, it will use the outputCol. This allows caching of the
transformed data when necessary.
dataset - The dataset to search for nearest neighbors of the key.key - Feature vector representing the item to search for.numNearestNeighbors - The maximum number of nearest neighbors.distCol - Output column for storing the distance between each result row and the key.public Dataset<?> approxNearestNeighbors(Dataset<?> dataset, Vector key, int numNearestNeighbors)
dataset - (undocumented)key - (undocumented)numNearestNeighbors - (undocumented)public Dataset<?> approxSimilarityJoin(Dataset<?> datasetA, Dataset<?> datasetB, double threshold, String distCol)
outputCol is missing, the method will transform the data; if the
outputCol exists, it will use the outputCol. This allows caching of the transformed
data when necessary.
datasetA - One of the datasets to join.datasetB - Another dataset to join.threshold - The threshold for the distance of row pairs.distCol - Output column for storing the distance between each pair of rows.public Dataset<?> approxSimilarityJoin(Dataset<?> datasetA, Dataset<?> datasetB, double threshold)
datasetA - (undocumented)datasetB - (undocumented)threshold - (undocumented)public Dataset<Row> transform(Dataset<?> dataset)
Transformertransform in class Transformerdataset - (undocumented)public StructType transformSchema(StructType schema)
PipelineStageCheck 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 PipelineStageschema - (undocumented)