jsat.datatransform
Class JLTransform
- java.lang.Object
-
- jsat.datatransform.DataTransformBase
-
- jsat.datatransform.JLTransform
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, DataTransform, Parameterized
public class JLTransform extends DataTransformBase
The Johnson-Lindenstrauss (JL) Transform is a type of random projection down to a lower dimensional space. The goal is, with a high probability, to keep theEuclidean distancesbetween points approximately the same in the original and projected space.
The JL lemma, with a high probability, bounds the error of a distance computation between two points u and v in the lower dimensional space by (1 ± ε) d(u, v)2, where d is the Euclidean distance. It works best for very high dimension problems, 1000 or more.
For more information see:
Achlioptas, D. (2003). Database-friendly random projections: Johnson-Lindenstrauss with binary coins. Journal of Computer and System Sciences, 66(4), 671–687. doi:10.1016/S0022-0000(03)00025-4- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class and Description static classJLTransform.TransformModeDetermines which distribution to construct the transform matrix from
-
Constructor Summary
Constructors Constructor and Description JLTransform()Creates a new JL Transform that uses a target dimension of 50 features.JLTransform(int k)Creates a new JL TransformJLTransform(int k, JLTransform.TransformMode mode)Creates a new JL TransformJLTransform(int k, JLTransform.TransformMode mode, boolean inMemory)Creates a new JL Transform
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description DataTransformclone()voidfit(DataSet data)Fits this transform to the given dataset.JLTransform.TransformModegetMode()intgetProjectedDimension()static DistributionguessProjectedDimension(DataSet d)booleanisInMemory()voidsetInMemory(boolean inMemory)Sets whether or not the transform matrix is stored explicitly in memory or not.voidsetMode(JLTransform.TransformMode mode)The JL transform uses a random matrix to project the data, and the mode controls which method is used to construct this matrix.voidsetProjectedDimension(int k)Sets the target dimension size to use for the outputDataPointtransform(DataPoint dp)Returns a new data point that is a transformation of the original data point.-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface jsat.parameters.Parameterized
getParameter, getParameters
-
-
-
-
Constructor Detail
-
JLTransform
public JLTransform()
Creates a new JL Transform that uses a target dimension of 50 features. This may not be optimal for any particular dataset.- Parameters:
k- the target dimension size
-
JLTransform
public JLTransform(int k)
Creates a new JL Transform- Parameters:
k- the target dimension size
-
JLTransform
public JLTransform(int k, JLTransform.TransformMode mode)Creates a new JL Transform- Parameters:
k- the target dimension sizemode- how to construct the transformrand- the source of randomness
-
JLTransform
public JLTransform(int k, JLTransform.TransformMode mode, boolean inMemory)Creates a new JL Transform- Parameters:
k- the target dimension sizemode- how to construct the transforminMemory- iffalse, the matrix will be stored in O(1) memory at the cost of execution time.
-
-
Method Detail
-
fit
public void fit(DataSet data)
Description copied from interface:DataTransformFits this transform to the given dataset. Some transforms can only be learned from classification or regression datasets. If an incompatible dataset type is given, aFailedToFitExceptionexception may be thrown.- Parameters:
data- the dataset to fir this transform to
-
setMode
public void setMode(JLTransform.TransformMode mode)
The JL transform uses a random matrix to project the data, and the mode controls which method is used to construct this matrix.- Parameters:
mode- how to construct the transform
-
getMode
public JLTransform.TransformMode getMode()
- Returns:
- how to construct the transform
-
setInMemory
public void setInMemory(boolean inMemory)
Sets whether or not the transform matrix is stored explicitly in memory or not. Explicit storage is often faster, but can be prohibitive for large datasets- Parameters:
inMemory-trueto explicitly store the transform matrix,falseto re-create it on the fly as needed
-
isInMemory
public boolean isInMemory()
- Returns:
trueif this object will explicitly store the transform matrix,falseto re-create it on the fly as needed
-
setProjectedDimension
public void setProjectedDimension(int k)
Sets the target dimension size to use for the output- Parameters:
k- the dimension after apply the transform
-
getProjectedDimension
public int getProjectedDimension()
- Returns:
- the dimension after apply the transform
-
guessProjectedDimension
public static Distribution guessProjectedDimension(DataSet d)
-
transform
public DataPoint transform(DataPoint dp)
Description copied from interface:DataTransformReturns a new data point that is a transformation of the original data point. This new data point is a different object, but may contain the same references as the original data point. It is not guaranteed that you can mutate the transformed point without having a side effect on the original point.- Parameters:
dp- the data point to apply a transformation to- Returns:
- a transformed data point
-
clone
public DataTransform clone()
- Specified by:
clonein interfaceDataTransform- Specified by:
clonein classDataTransformBase
-
-
DataMelt 3.0 © DataMelt by jWork.ORG