jsat.datatransform.kernel
Class KernelPCA
- java.lang.Object
-
- jsat.datatransform.DataTransformBase
-
- jsat.datatransform.kernel.KernelPCA
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, DataTransform, Parameterized
public class KernelPCA extends DataTransformBase
A kernelized implementation ofPCA. Because this works in a different feature space, it will do its own centering in the kernel space.
KernelPCA is expensive to compute at O(n3) work, where n is the number of data points. For this reason, sampling fromNystromis used to reduce the data set to a reasonable approximation.
See: Schölkopf, B., Smola, A.,&Müller, K.-R. (1998). Nonlinear Component Analysis as a Kernel Eigenvalue Problem. Neural Computation, 10(5), 1299–1319. doi:10.1162/089976698300017467- See Also:
Nystrom.SamplingMethod, Serialized Form
-
-
Constructor Summary
Constructors Constructor and Description KernelPCA()Creates a new Kernel PCA transform object using theRBF Kerneland 100 dimensionsKernelPCA(int dimensions)Creates a new Kernel PCA transform object using theRBF KernelKernelPCA(KernelTrick k, DataSet ds, int dimensions, int basisSize, Nystrom.SamplingMethod samplingMethod)Creates a new Kernel PCA transform objectKernelPCA(KernelTrick k, int dimensions)Creates a new Kernel PCA transform objectKernelPCA(KernelTrick k, int dimensions, int basisSize, Nystrom.SamplingMethod samplingMethod)Creates a new Kernel PCA transform object
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description KernelPCAclone()voidfit(DataSet ds)Fits this transform to the given dataset.Nystrom.SamplingMethodgetBasisSamplingMethod()Returns the method of selecting the basis vectorsintgetBasisSize()Returns the number of basis vectors to useintgetDimensions()Returns the number of dimensions to project down tooKernelTrickgetKernel()static DistributionguessDimensions(DataSet d)voidsetBasisSamplingMethod(Nystrom.SamplingMethod method)Sets the method of selecting the basis vectorsvoidsetBasisSize(int basisSize)Sets the basis size for the Kernel PCA to be learned from.voidsetDimensions(int dimensions)Sets the dimension of the new feature space, which is the number of principal components to select from the kernelized feature space.voidsetKernel(KernelTrick k)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
-
KernelPCA
public KernelPCA()
Creates a new Kernel PCA transform object using theRBF Kerneland 100 dimensions
-
KernelPCA
public KernelPCA(int dimensions)
Creates a new Kernel PCA transform object using theRBF Kernel- Parameters:
dimensions- the number of dimensions to project down to. Must be less than than the basis size
-
KernelPCA
public KernelPCA(KernelTrick k, int dimensions)
Creates a new Kernel PCA transform object- Parameters:
k- the kernel trick to usedimensions- the number of dimensions to project down to. Must be less than than the basis size
-
KernelPCA
public KernelPCA(KernelTrick k, int dimensions, int basisSize, Nystrom.SamplingMethod samplingMethod)
Creates a new Kernel PCA transform object- Parameters:
k- the kernel trick to usedimensions- the number of dimensions to project down to. Must be less than than the basis sizebasisSize- the number of points from the data set to select. If larger than the number of data points in the data set, the whole data set will be used.samplingMethod- the sampling method to select the basis vectors
-
KernelPCA
public KernelPCA(KernelTrick k, DataSet ds, int dimensions, int basisSize, Nystrom.SamplingMethod samplingMethod)
Creates a new Kernel PCA transform object- Parameters:
k- the kernel trick to useds- the data set to form the data transform fromdimensions- the number of dimensions to project down to. Must be less than than the basis sizebasisSize- the number of points from the data set to select. If larger than the number of data points in the data set, the whole data set will be used.samplingMethod- the sampling method to select the basis vectors
-
-
Method Detail
-
fit
public void fit(DataSet ds)
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:
ds- 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 KernelPCA clone()
- Specified by:
clonein interfaceDataTransform- Specified by:
clonein classDataTransformBase
-
setKernel
public void setKernel(KernelTrick k)
- Parameters:
k- the kernel trick to use
-
getKernel
public KernelTrick getKernel()
- Returns:
- the kernel trick to use
-
setBasisSize
public void setBasisSize(int basisSize)
Sets the basis size for the Kernel PCA to be learned from. Increasing the basis increase the accuracy of the transform, but increased the training time at a cubic rate.- Parameters:
basisSize- the number of basis vectors to build Kernel PCA from
-
getBasisSize
public int getBasisSize()
Returns the number of basis vectors to use- Returns:
- the number of basis vectors to use
-
setDimensions
public void setDimensions(int dimensions)
Sets the dimension of the new feature space, which is the number of principal components to select from the kernelized feature space.- Parameters:
dimensions- the number of dimensions to project down too
-
getDimensions
public int getDimensions()
Returns the number of dimensions to project down too- Returns:
- the number of dimensions to project down too
-
setBasisSamplingMethod
public void setBasisSamplingMethod(Nystrom.SamplingMethod method)
Sets the method of selecting the basis vectors- Parameters:
method- the method of selecting the basis vectors
-
getBasisSamplingMethod
public Nystrom.SamplingMethod getBasisSamplingMethod()
Returns the method of selecting the basis vectors- Returns:
- the method of selecting the basis vectors
-
guessDimensions
public static Distribution guessDimensions(DataSet d)
-
-
DataMelt 3.0 © DataMelt by jWork.ORG