Package edu.cmu.tetrad.search
Class FastIca
java.lang.Object
edu.cmu.tetrad.search.FastIca
FastICA (real-valued) translated for Tetrad.
Key stability fixes: - Correct derivative in symmetric (parallel) update: g'(u) = α(1 - g(u)^2) for logcosh. - Whitening ridge (eps) to avoid exploding 1/sqrt(λ) on tiny eigenvalues. - Orthonormalize random wInit via SVD (helps convergence). - Small deflation loop fix (row assignment index).
Reference: Hyvarinen & Oja (2000) Independent Component Analysis: Algorithms and Applications. Neural Networks 13(4–5):411–430.
- Version:
- $Id: $Id
- Author:
- josephramsey
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordA record that represents the result of the Independent Component Analysis (ICA) process. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidCenters the rows of the given matrix by subtracting the mean of each row from its elements.Run FastICA and return preprocessed X, whitening K, unmixing W, and sources S.voidsetAlgorithmType(int algorithmType) Sets the algorithm type to be used in the FastICA computation.voidsetAlpha(double alpha) Sets the alpha parameter for the FastICA algorithm.voidsetFunction(int function) Sets the function to be used for the ICA algorithm.voidsetMaxIterations(int maxIterations) Sets the maximum number of iterations for the FastICA algorithm.voidsetRowNorm(boolean rowNorm) Sets whether row normalization should be applied.voidsetTolerance(double tolerance) Sets the tolerance value for convergence in the FastICA algorithm.voidsetVerbose(boolean verbose) Enables or disables verbose mode for the FastICA algorithm.voidSets the initial weights matrix to be used for the FastICA algorithm.
-
Field Details
-
PARALLEL
public static int PARALLELExtract components simultaneously (symmetric decorrelation). -
DEFLATION
public static int DEFLATIONExtract components one-at-a-time. -
LOGCOSH
public static int LOGCOSHNeg-entropy nonlinearity: logcosh. -
EXP
public static int EXPNeg-entropy nonlinearity: exp.
-
-
Constructor Details
-
FastIca
Constructs a FastIca object with the given data matrix and number of components.- Parameters:
X- The input data matrix where each row represents a signal and each column is a feature.numComponents- The number of independent components to extract from the input data.
-
-
Method Details
-
center
Centers the rows of the given matrix by subtracting the mean of each row from its elements. This operation adjusts the data so that each row has a mean value of zero.- Parameters:
x- The input matrix to be centered. Each row will have its mean value subtracted from its elements.
-
setAlgorithmType
public void setAlgorithmType(int algorithmType) Sets the algorithm type to be used in the FastICA computation. The algorithm type determines the approach for extracting independent components and must be either DEFLATION or PARALLEL.- Parameters:
algorithmType- the type of algorithm to use. Acceptable values are FastIca.DEFLATION for the deflation approach or FastIca.PARALLEL for the parallel approach.- Throws:
IllegalArgumentException- if the value is not DEFLATION or PARALLEL.
-
setFunction
public void setFunction(int function) Sets the function to be used for the ICA algorithm. The function determines the non-linear processing applied during the computation. Acceptable values are FastIca.LOGCOSH or FastIca.EXP.- Parameters:
function- The non-linear function type to be used. Must be either LOGCOSH or EXP.- Throws:
IllegalArgumentException- if the value is not FastIca.LOGCOSH or FastIca.EXP.
-
setAlpha
public void setAlpha(double alpha) Sets the alpha parameter for the FastICA algorithm. The alpha parameter influences the non-linearity used during computation and must be within the range [1, 2].- Parameters:
alpha- The value to set for the alpha parameter. Must be within the range [1, 2].- Throws:
IllegalArgumentException- if the provided alpha value is outside the range [1, 2].
-
setRowNorm
public void setRowNorm(boolean rowNorm) Sets whether row normalization should be applied. Row normalization adjusts the rows of the data matrix to ensure uniform scaling.- Parameters:
rowNorm- A boolean value indicating whether row normalization is enabled (true) or disabled (false).
-
setMaxIterations
public void setMaxIterations(int maxIterations) Sets the maximum number of iterations for the FastICA algorithm. The algorithm will terminate if the maximum number of iterations is reached before convergence.- Parameters:
maxIterations- the maximum number of iterations to be set. It must be a positive integer.
-
setTolerance
public void setTolerance(double tolerance) Sets the tolerance value for convergence in the FastICA algorithm. This determines the threshold for stopping the iterative process based on the change in component values. The tolerance must be a positive value.- Parameters:
tolerance- The convergence tolerance to be set. Must be a positive value.
-
setVerbose
public void setVerbose(boolean verbose) Enables or disables verbose mode for the FastICA algorithm. When verbose mode is enabled, detailed information about the algorithm's progress and intermediate steps may be logged or displayed.- Parameters:
verbose- A boolean value indicating whether verbose mode is enabled (true) or disabled (false).
-
setWInit
Sets the initial weights matrix to be used for the FastICA algorithm.- Parameters:
wInit- The initial weights matrix. This matrix is used as the starting point for the algorithm to compute the independent components.
-
findComponents
Run FastICA and return preprocessed X, whitening K, unmixing W, and sources S.- Returns:
- IcaResult containing preprocessed X, whitening K, unmixing W, and sources S.
-