MCPcopy Create free account
hub / github.com/EdwardRaff/JSAT / PCA

Class PCA

JSAT/src/jsat/datatransform/PCA.java:35–277  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

33 * @see ZeroMeanTransform
34 */
35public class PCA implements DataTransform
36{
37
38 private static final long serialVersionUID = 8736609877239941617L;
39 /**
40 * The transposed matrix of the Principal Components
41 */
42 private Matrix P;
43 private int maxPCs;
44 private double threshold;
45
46 /**
47 * Creates a new object for performing PCA that stops at 50 principal components. This may not be optimal for any particular dataset
48 *
49 */
50 public PCA()
51 {
52 this(50);
53 }
54
55 /**
56 * Performs PCA analysis using the given data set, so that transformations may be performed on future data points. <br>
57 * <br>
58 * NOTE: The maximum number of PCs will be learned until a convergence threshold is meet. It is possible that the
59 * number of PCs computed will be equal to the number of dimensions, meaning no dimensionality reduction has
60 * occurred, but a transformation of the dimensions into a new space.
61 *
62 * @param dataSet the data set to learn from
63 */
64 public PCA(DataSet dataSet)
65 {
66 this(dataSet, Integer.MAX_VALUE);
67 }
68
69 /**
70 * Performs PCA analysis using the given data set, so that transformations may be performed on future data points.
71 *
72 * @param dataSet the data set to learn from
73 * @param maxPCs the maximum number of Principal Components to let the algorithm learn. The algorithm may stop
74 * earlier if all the variance has been explained, or the convergence threshold has been met.
75 * Note, the computable maximum number of PCs is limited to the minimum of the number of samples and the
76 * number of dimensions.
77 */
78 public PCA(DataSet dataSet, int maxPCs)
79 {
80 this(dataSet, maxPCs, 1e-4);
81 }
82
83 /**
84 * Creates a new object for performing PCA
85 *
86 * @param maxPCs the maximum number of Principal Components to let the
87 * algorithm learn. The algorithm may stop earlier if all the variance has
88 * been explained, or the convergence threshold has been met. Note, the
89 * computable maximum number of PCs is limited to the minimum of the number
90 * of samples and the number of dimensions.
91 */
92 public PCA(int maxPCs)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected