jsat.datatransform
Class PCA
- java.lang.Object
-
- jsat.datatransform.PCA
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, DataTransform
public class PCA extends java.lang.Object implements DataTransform
Principle Component Analysis is a method that attempts to create a basis of the given space that maintains the variance in the data set while eliminating correlation of the variables.
When a full basis is formed, the dimensionality will remain the same, but the data will be transformed to a new space.
PCA is particularly useful when a small number of basis can explain most of the variance in the data set that is not related to noise, maintaining information while reducing the dimensionality of the data.
PCA works only on the numerical attributes of a data set.
For PCA to work correctly, aZeroMeanTransformshould be applied to the data set first. If not done, the first dimension of PCA may contain noise and become uninformative, possibly throwing off the computation of the other PCs- See Also:
ZeroMeanTransform, Serialized Form
-
-
Constructor Summary
Constructors Constructor and Description PCA()Creates a new object for performing PCA that stops at 50 principal components.PCA(DataSet dataSet)Performs PCA analysis using the given data set, so that transformations may be performed on future data points.PCA(DataSet dataSet, int maxPCs)Performs PCA analysis using the given data set, so that transformations may be performed on future data points.PCA(DataSet dataSet, int maxPCs, double threshold)Performs PCA analysis using the given data set, so that transformations may be performed on future data points.PCA(int maxPCs)Creates a new object for performing PCAPCA(int maxPCs, double threshold)Creates a new object for performing PCA
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description DataTransformclone()voidfit(DataSet dataSet)Fits this transform to the given dataset.intgetMaxPCs()doublegetThreshold()voidsetMaxPCs(int maxPCs)sets the maximum number of principal components to learnvoidsetThreshold(double threshold)DataPointtransform(DataPoint dp)Returns a new data point that is a transformation of the original data point.
-
-
-
Constructor Detail
-
PCA
public PCA()
Creates a new object for performing PCA that stops at 50 principal components. This may not be optimal for any particular dataset
-
PCA
public PCA(DataSet dataSet)
Performs PCA analysis using the given data set, so that transformations may be performed on future data points.
NOTE: The maximum number of PCs will be learned until a convergence threshold is meet. It is possible that the number of PCs computed will be equal to the number of dimensions, meaning no dimensionality reduction has occurred, but a transformation of the dimensions into a new space.- Parameters:
dataSet- the data set to learn from
-
PCA
public PCA(DataSet dataSet, int maxPCs)
Performs PCA analysis using the given data set, so that transformations may be performed on future data points.- Parameters:
dataSet- the data set to learn frommaxPCs- the maximum number of Principal Components to let the algorithm learn. The algorithm may stop earlier if all the variance has been explained, or the convergence threshold has been met. Note, the computable maximum number of PCs is limited to the minimum of the number of samples and the number of dimensions.
-
PCA
public PCA(int maxPCs)
Creates a new object for performing PCA- Parameters:
maxPCs- the maximum number of Principal Components to let the algorithm learn. The algorithm may stop earlier if all the variance has been explained, or the convergence threshold has been met. Note, the computable maximum number of PCs is limited to the minimum of the number of samples and the number of dimensions.
-
PCA
public PCA(int maxPCs, double threshold)Creates a new object for performing PCA- Parameters:
maxPCs- the maximum number of Principal Components to let the algorithm learn. The algorithm may stop earlier if all the variance has been explained, or the convergence threshold has been met. Note, the computable maximum number of PCs is limited to the minimum of the number of samples and the number of dimensions.threshold- a convergence threshold, any small value will work. Smaller values will not produce more accurate results, but may make the algorithm take longer if it would have terminated before maxPCs was reached.
-
PCA
public PCA(DataSet dataSet, int maxPCs, double threshold)
Performs PCA analysis using the given data set, so that transformations may be performed on future data points.- Parameters:
dataSet- the data set to learn frommaxPCs- the maximum number of Principal Components to let the algorithm learn. The algorithm may stop earlier if all the variance has been explained, or the convergence threshold has been met. Note, the computable maximum number of PCs is limited to the minimum of the number of samples and the number of dimensions.threshold- a convergence threshold, any small value will work. Smaller values will not produce more accurate results, but may make the algorithm take longer if it would have terminated before maxPCs was reached.
-
-
Method Detail
-
fit
public void fit(DataSet dataSet)
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.- Specified by:
fitin interfaceDataTransform- Parameters:
dataSet- the dataset to fir this transform to
-
setMaxPCs
public void setMaxPCs(int maxPCs)
sets the maximum number of principal components to learn- Parameters:
maxPCs- the maximum number of principal components to learn
-
getMaxPCs
public int getMaxPCs()
- Returns:
- maximum number of principal components to learn
-
setThreshold
public void setThreshold(double threshold)
- Parameters:
threshold- the threshold for convergence of the algorithm
-
getThreshold
public double getThreshold()
-
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.- Specified by:
transformin interfaceDataTransform- Parameters:
dp- the data point to apply a transformation to- Returns:
- a transformed data point
-
clone
public DataTransform clone()
- Specified by:
clonein interfaceDataTransform- Overrides:
clonein classjava.lang.Object
-
-
DataMelt 3.0 © DataMelt by jWork.ORG