public class BucketedRandomProjectionLSH extends Estimator<T> implements BucketedRandomProjectionLSHParams, HasSeed
BucketedRandomProjectionLSH
implements Locality Sensitive Hashing functions for
Euclidean distance metrics.
The input is dense or sparse vectors, each of which represents a point in the Euclidean distance space. The output will be vectors of configurable dimension. Hash values in the same dimension are calculated by the same hash function.
References:
1. Wikipedia on Stable Distributions
2. Wang, Jingdong et al. "Hashing for similarity search: A survey." arXiv preprint arXiv:1408.2927 (2014).
Constructor and Description |
---|
BucketedRandomProjectionLSH() |
BucketedRandomProjectionLSH(String uid) |
Modifier and Type | Method and Description |
---|---|
DoubleParam |
bucketLength()
The length of each hash bucket, a larger bucket lowers the false negative rate.
|
BucketedRandomProjectionLSH |
copy(ParamMap extra)
Creates a copy of this instance with the same UID and some extra params.
|
T |
fit(Dataset<?> dataset)
Fits a model to the input data.
|
Param<String> |
inputCol()
Param for input column name.
|
static BucketedRandomProjectionLSH |
load(String path) |
IntParam |
numHashTables()
Param for the number of hash tables used in LSH OR-amplification.
|
Param<String> |
outputCol()
Param for output column name.
|
static MLReader<T> |
read() |
LongParam |
seed()
Param for random seed.
|
BucketedRandomProjectionLSH |
setBucketLength(double value) |
BucketedRandomProjectionLSH |
setInputCol(String value) |
BucketedRandomProjectionLSH |
setNumHashTables(int value) |
BucketedRandomProjectionLSH |
setOutputCol(String value) |
BucketedRandomProjectionLSH |
setSeed(long value) |
StructType |
transformSchema(StructType schema)
Check transform validity and derive the output schema from the input schema.
|
String |
uid()
An immutable unique ID for the object and its derivatives.
|
params
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getBucketLength
clear, copyValues, defaultCopy, defaultParamMap, explainParam, explainParams, extractParamMap, extractParamMap, get, getDefault, getOrDefault, getParam, hasDefault, hasParam, isDefined, isSet, onParamChange, paramMap, params, set, set, set, setDefault, setDefault, shouldOwn
toString
getNumHashTables, validateAndTransformSchema
getInputCol
getOutputCol
write
save
$init$, initializeForcefully, initializeLogIfNecessary, initializeLogIfNecessary, initializeLogIfNecessary$default$2, initLock, isTraceEnabled, log, logDebug, logDebug, logError, logError, logInfo, logInfo, logName, logTrace, logTrace, logWarning, logWarning, org$apache$spark$internal$Logging$$log__$eq, org$apache$spark$internal$Logging$$log_, uninitialize
public BucketedRandomProjectionLSH(String uid)
public BucketedRandomProjectionLSH()
public static BucketedRandomProjectionLSH load(String path)
public static MLReader<T> read()
public final LongParam seed()
HasSeed
public DoubleParam bucketLength()
BucketedRandomProjectionLSHParams
(max L2 norm of input vectors) / bucketLength
.
If input vectors are normalized, 1-10 times of pow(numRecords, -1/inputDim) would be a reasonable value
bucketLength
in interface BucketedRandomProjectionLSHParams
public String uid()
Identifiable
uid
in interface Identifiable
public BucketedRandomProjectionLSH setInputCol(String value)
public BucketedRandomProjectionLSH setOutputCol(String value)
public BucketedRandomProjectionLSH setNumHashTables(int value)
public BucketedRandomProjectionLSH setBucketLength(double value)
public BucketedRandomProjectionLSH setSeed(long value)
public StructType transformSchema(StructType schema)
PipelineStage
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 BucketedRandomProjectionLSH copy(ParamMap extra)
Params
defaultCopy()
.copy
in interface Params
copy
in class Estimator<BucketedRandomProjectionLSHModel>
extra
- (undocumented)public T fit(Dataset<?> dataset)
Estimator
public final Param<String> inputCol()
HasInputCol
inputCol
in interface HasInputCol
public final IntParam numHashTables()
LSHParams
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.
numHashTables
in interface LSHParams
public final Param<String> outputCol()
HasOutputCol
outputCol
in interface HasOutputCol