public class BucketedRandomProjectionLSH extends Estimator<T>
This 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 |
|---|---|
static DoubleParam |
bucketLength() |
DoubleParam |
bucketLength()
The length of each hash bucket, a larger bucket lowers the false negative rate.
|
static Params |
clear(Param<?> param) |
BucketedRandomProjectionLSH |
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) |
static T |
fit(Dataset<?> dataset) |
T |
fit(Dataset<?> dataset)
Fits a model to the input data.
|
static M |
fit(Dataset<?> dataset,
ParamMap paramMap) |
static scala.collection.Seq<M> |
fit(Dataset<?> dataset,
ParamMap[] paramMaps) |
static M |
fit(Dataset<?> dataset,
ParamPair<?> firstParamPair,
ParamPair<?>... otherParamPairs) |
static M |
fit(Dataset<?> dataset,
ParamPair<?> firstParamPair,
scala.collection.Seq<ParamPair<?>> otherParamPairs) |
static <T> scala.Option<T> |
get(Param<T> param) |
static double |
getBucketLength() |
double |
getBucketLength() |
static <T> scala.Option<T> |
getDefault(Param<T> param) |
static String |
getInputCol() |
String |
getInputCol() |
static int |
getNumHashTables() |
int |
getNumHashTables() |
static <T> T |
getOrDefault(Param<T> param) |
static String |
getOutputCol() |
String |
getOutputCol() |
static Param<Object> |
getParam(String paramName) |
static long |
getSeed() |
static <T> boolean |
hasDefault(Param<T> param) |
static boolean |
hasParam(String paramName) |
static Param<String> |
inputCol() |
Param<String> |
inputCol()
Param for input column name.
|
static boolean |
isDefined(Param<?> param) |
static boolean |
isSet(Param<?> param) |
static BucketedRandomProjectionLSH |
load(String path) |
static IntParam |
numHashTables() |
IntParam |
numHashTables()
Param for the number of hash tables used in LSH OR-amplification.
|
static Param<String> |
outputCol() |
Param<String> |
outputCol()
Param for output column name.
|
static Param<?>[] |
params() |
static void |
save(String path) |
static LongParam |
seed() |
static <T> Params |
set(Param<T> param,
T value) |
BucketedRandomProjectionLSH |
setBucketLength(double value) |
BucketedRandomProjectionLSH |
setInputCol(String value) |
BucketedRandomProjectionLSH |
setNumHashTables(int value) |
BucketedRandomProjectionLSH |
setOutputCol(String value) |
BucketedRandomProjectionLSH |
setSeed(long value) |
static String |
toString() |
StructType |
transformSchema(StructType schema)
:: DeveloperApi ::
|
String |
uid()
An immutable unique ID for the object and its derivatives.
|
StructType |
validateAndTransformSchema(StructType schema)
Transform the Schema for LSH
|
static MLWriter |
write() |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitclear, copyValues, defaultCopy, defaultParamMap, explainParam, explainParams, extractParamMap, extractParamMap, get, getDefault, getOrDefault, getParam, hasDefault, hasParam, isDefined, isSet, paramMap, params, set, set, set, setDefault, setDefault, shouldOwntoStringwritesavepublic BucketedRandomProjectionLSH(String uid)
public BucketedRandomProjectionLSH()
public static BucketedRandomProjectionLSH 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 M fit(Dataset<?> dataset, ParamPair<?> firstParamPair, scala.collection.Seq<ParamPair<?>> otherParamPairs)
public static M fit(Dataset<?> dataset, ParamPair<?> firstParamPair, ParamPair<?>... otherParamPairs)
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 numHashTables()
public static final int getNumHashTables()
public static void save(String path)
throws java.io.IOException
java.io.IOExceptionpublic static MLWriter write()
public static T fit(Dataset<?> dataset)
public static DoubleParam bucketLength()
public static final double getBucketLength()
public static final LongParam seed()
public static final long getSeed()
public String uid()
Identifiableuid in interface Identifiablepublic 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)
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)public BucketedRandomProjectionLSH copy(ParamMap extra)
ParamsdefaultCopy().copy in interface Paramscopy in class Estimator<BucketedRandomProjectionLSHModel>extra - (undocumented)public DoubleParam bucketLength()
(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
public double getBucketLength()
public T fit(Dataset<?> dataset)
Estimatorpublic IntParam numHashTables()
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.
public int getNumHashTables()
public StructType validateAndTransformSchema(StructType schema)
schema - The schema of the input dataset without outputCol.outputCol added.public Param<String> inputCol()
public String getInputCol()
public Param<String> outputCol()
public String getOutputCol()