jsat.datatransform.kernel
Class RFF_RBF
- java.lang.Object
-
- jsat.datatransform.DataTransformBase
-
- jsat.datatransform.kernel.RFF_RBF
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, DataTransform, Parameterized
public class RFF_RBF extends DataTransformBase
An Implementation of Random Fourier Features for theRBFKernel. It transforms the numerical variables of a feature space to form a new feature space where the dot product between features approximates the RBF Kernel product.
See: Rahimi, A.,&Recht, B. (2007). Random Features for Large-Scale Kernel Machines. Neural Information Processing Systems. Retrieved from here- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor and Description RFF_RBF()Creates a new RFF RBF object that will use an transformed feature space with a dimensionality of 512.RFF_RBF(double sigma)Creates a new RFF RBF object that will use an transformed feature space with a dimensionality of 512.RFF_RBF(double sigma, int dim)Creates a new RFF RBF objectRFF_RBF(double sigma, int dim, boolean inMemory)Creates a new RFF RBF objectRFF_RBF(int featurSize, double sigma, int dim, java.util.Random rand, boolean inMemory)Creates a new RFF RBF object
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description RFF_RBFclone()voidfit(DataSet data)Fits this transform to the given dataset.intgetDimensions()Returns the number of dimensions that will be used in the projected spacedoublegetSigma()Returns the σ value used for the RBF kernel approximation.DistributionguessSigma(DataSet d)Guess the distribution to use for the kernel width termσin the RBF kernel being approximated.booleanisInMemory()voidsetDimensions(int dimensions)Sets the number of dimensions in the new approximate space to use.voidsetInMemory(boolean inMemory)Sets whether or not the transform matrix is stored explicitly in memory or not.voidsetSigma(double sigma)Sets the σ parameter of the RBF kernel that is being approximated.DataPointtransform(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
-
RFF_RBF
public RFF_RBF()
Creates a new RFF RBF object that will use an transformed feature space with a dimensionality of 512. This constructor should be used with a parameter search to find a good value forsigma
-
RFF_RBF
public RFF_RBF(double sigma)
Creates a new RFF RBF object that will use an transformed feature space with a dimensionality of 512.- Parameters:
sigma- the positive sigma value for theRBFKernel
-
RFF_RBF
public RFF_RBF(double sigma, int dim)Creates a new RFF RBF object- Parameters:
sigma- the positive sigma value for theRBFKerneldim- the new feature size dimension to project into.
-
RFF_RBF
public RFF_RBF(double sigma, int dim, boolean inMemory)Creates a new RFF RBF object- Parameters:
sigma- the positive sigma value for theRBFKerneldim- the new feature size dimension to project into.inMemory-trueif the internal matrix should be stored in memory. Iffalse, the memory will be re-computed as needed, increasing computation cost but uses no extra memory.
-
RFF_RBF
public RFF_RBF(int featurSize, double sigma, int dim, java.util.Random rand, boolean inMemory)Creates a new RFF RBF object- Parameters:
featurSize- the number of numeric features in the original feature spacesigma- the positive sigma value for theRBFKerneldim- the new feature size dimension to project into.rand- the source of randomness to initialize internal stateinMemory-trueif the internal matrix should be stored in memory. Iffalse, the memory will be re-computed as needed, increasing computation cost but uses no extra memory.
-
-
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
-
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 RFF_RBF clone()
- Specified by:
clonein interfaceDataTransform- Specified by:
clonein classDataTransformBase
-
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 feature sizes- 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
-
setDimensions
public void setDimensions(int dimensions)
Sets the number of dimensions in the new approximate space to use. This will be the number of numeric features in the transformed data, and larger values increase the accuracy of the approximation.- Parameters:
dimensions-
-
getDimensions
public int getDimensions()
Returns the number of dimensions that will be used in the projected space- Returns:
- the number of dimensions that will be used in the projected space
-
setSigma
public void setSigma(double sigma)
Sets the σ parameter of the RBF kernel that is being approximated.- Parameters:
sigma- the positive value to use for σ- See Also:
RBFKernel.setSigma(double)
-
getSigma
public double getSigma()
Returns the σ value used for the RBF kernel approximation.- Returns:
- the σ value used for the RBF kernel approximation.
-
guessSigma
public Distribution guessSigma(DataSet d)
Guess the distribution to use for the kernel width termσin the RBF kernel being approximated.- Parameters:
d- the data set to get the guess for- Returns:
- the guess for the σ parameter in the RBF Kernel
-
-
DataMelt 3.0 © DataMelt by jWork.ORG