pyeeg.models._svd_regress

pyeeg.models._svd_regress(x, y, alpha=0.0, verbose=False)

Linear regression using svd.

Parameters:
  • x (ndarray (nsamples, nfeats) or list of such) – If a list of such is given (with possibly different nsamples), covariance matrices will be computed by accumulating them for each trials. The number of samples must then be the same in both x and y per each trial.

  • y (ndarray (nsamples, nchans) or list of such) – If a list of such arrays is given, each element of the list is treated as an individual subject, the resulting betas coefficients are thus computed on the averaged covariance matrices.

  • alpha (float or array-like) – If array, will compute betas for every regularisation parameters at once

Returns:

betas – Coefficients

Return type:

ndarray (nfeats, nchans, len(alpha))

Raises:
  • ValueError – If alpha < 0 (coefficient of L2 - regularization)

  • AssertionError – If trial length for each x and y differ.

Notes

A warning is shown in the case where nfeats > nsamples, if so the user should rather use partial regression.