Methods Comparison¶
- class dca.methods_comparison.ForecastableComponentsAnalysis(d, T, init='random_ortho', n_init=1, tol=1e-06, verbose=False, device='cpu', dtype=torch.float64, rng_or_seed=20200818)[source]¶
Forecastable Components Analysis.
Runs FCA on multidimensional timeseries data X to discover a projection onto a d-dimensional subspace which maximizes the entropy of the power spectrum.
Based on http://proceedings.mlr.press/v28/goerg13.html, but does not calculate the gradients in the same way. This implementation uses autograd.
Note: this has not been carefully tested.
- Parameters:
d (int) – Number of basis vectors onto which the data X are projected.
T (int) – Size of time windows accross which to compute mutual information.
init (string) – Options: “random”, “PCA” Method for initializing the projection matrix.
- class dca.methods_comparison.GaussianProcessFactorAnalysis(n_factors, var_n=0.001, tol=1e-08, max_iter=500, tau_init=10, seed=20190213, verbose=False)[source]¶
Gaussian Process Factor Analysis model.
Based on formulation in https://journals.physiology.org/doi/full/10.1152/jn.90941.2008.
- Parameters:
n_factors (int) – Number of latent factors.
var_n (float) – Independent noise for the factors.
tol (float) – The EM iterations stop when |L^k - L^{k+1}|/max{|L^k|,|L^{k+1}|,1} <= tol.
max_iter (int) – Maximum number of EM steps.
tau_init (float) – Scale for timescale initialization. Units are in sampling rate units.
- class dca.methods_comparison.JPCA(n_components=6, mean_subtract=True)[source]¶
Model for extracting rotational dynamics from timeseries data using jPCA.
As presented in https://www.nature.com/articles/nature11129. Based on code from https://churchland.zuckermaninstitute.columbia.edu/content/code.
- Parameters:
n_components (even int (default=6)) – Number of components to reduce X to.
mean_subtract (boolean (default=True)) – Whether to subtract the cross-condition mean from each condition before running jPCA.
- eigen_vecs_¶
List of numpy eigenvectors from JPCA skew symmetric matrix sorted in descending order by magnitude of eigenvalue.
- Type:
list
- eigen_vals_¶
List of eigenvalues from JPCA skew symmetric matrix. The index of each eigenvalue corresponds with the eigenvector in eigen_vecs_.
- Type:
list
- pca_¶
PCA object used to transform X to X_red.
- Type:
sklearn.decomp.PCA object
- cross_condition_mean_¶
Cross condition mean of X during fit.
- Type:
ndarray (time, features)
- proj_vectors_¶
List of projection vectors sorted in order by conjugate eigenvalue pairs.
- Type:
list
- fit(X)[source]¶
Fit a jPCA model to X.
- Parameters:
X (ndarray (conditions, time, features)) – Data to fit using jPCA model.
- Return type:
self
- fit_transform(X)[source]¶
Fit and transform X using JPCA.
- Parameters:
X (ndarray (conditions, time, features)) – Data to be transformed by JPCA.
- Returns:
X projected onto JPCA components.
- Return type:
ndarray (conditions*time, n_components)
- transform(X)[source]¶
Transform X using JPCA components.
- Parameters:
X (ndarray (conditions, time, features)) – Data to fit using jPCA model.
- Returns:
X projected onto jPCA components (conditions are preserved). In X_proj, every pair of features correspond to a conjugate pair of JPCA eigenvectors. The pairs are sorted by largest magnitude eigenvalue (i.e. dimensions 0 and 1 in X_proj contains the projection from the conjugate eigenvector pair with the largest eigenvalue magnitude). The projection pair is what captures the rotations.
- Return type:
ndarray (conditions, time, n_components)
- class dca.methods_comparison.SlowFeatureAnalysis(n_components)[source]¶
Slow Feature Analysis (SFA)
Based on https://www.mitpressjournals.org/doi/abs/10.1162/089976602317318938.
- Parameters:
n_components (int) – The number of components to learn.
- fit(X)[source]¶
Fit the SFA model.
- Parameters:
X (ndarray (time, features)) – Data to fit SFA model to.