fanok.factor_model package

Submodules

fanok.factor_model.factor_model module

class fanok.factor_model.factor_model.FactorModel

Bases: object

Abstraction of the covariance factor model. If the covariance (empirical or Ledoit-Wolf) is Sigma, computes a diagonal plus low-rank approximation of it.

Sigma = diag(d) + U * U^T

fit(X: numpy.ndarray)
transform()
class fanok.factor_model.factor_model.RandomizedLowRankFactorModel(rank: int, over_sample: int = 10, num_iterations: int = 2, shrink: bool = True, shrinkage_mode: str = 'random')

Bases: fanok.factor_model.factor_model.FactorModel

Randomized factor model estimation. Performs an alternating minimization scheme to converge to local optimality.

Parameters:
  • rank – Rank of the approximation
  • over_sample – How many more vectors than the rank to use

for the low-rank approximation. This is essentialy usefull for stability purposes when the rank is low. Defaults to 10. :param num_iterations: How many iterations to perform in the alternating minimization algorithms. :param shrink: Whether or not to shrink the covariance matrix (Ledoit-Wolf estimation). This is recommended in high dimension. Defaults to True. :param shrinkage_mode: How should the optimal shrinkage coefficient be computed, in case of Ledoit-Wolf estimation.

fit(X: numpy.ndarray)

Computes the diagonal plus low-rank approximation of the covariance estimated from the data samples.

Parameters:X – Data samples
transform()

Returns the covariance approximation.

fanok.factor_model.factor_model.ledoit_wolf_shrinkage(X: numpy.ndarray, s: numpy.ndarray = None, mode: str = 'exact', m: int = 20, n_v: int = 20)

Computes the Ledoit-Wolf optimal shrinkage coefficient from the sample X. It doesn’t evaluate the empirical covariance Sigma.

Parameters:
  • X – Data samples
  • s
  • mode – Method to compute the shrinkage.
  • m
  • n_v
fanok.factor_model.factor_model.randomized_factor_model(X: numpy.ndarray, rank: int = 5, over_sample: int = 10, num_iterations: int = 2, shrink: bool = True, shrinkage_mode: str = 'random', q: int = None, m: int = 20, n_v: int = 20)
Parameters:
  • X – Data samples
  • rank – Rank approximation. Defaults to 5
  • over_sample – How many more vectors than the rank to use

for the low-rank approximation. This is essentialy usefull for stability purposes when the rank is low. Defaults to 10. :param num_iterations: How many iterations to perform in the alternating minimization algorithms. :param shrink: Whether or not to shrink the covariance matrix (Ledoit-Wolf estimation). This is recommended in high dimension. Defaults to True. :param shrinkage_mode: How should the optimal shrinkage coefficient be computed, in case of Ledoit-Wolf estimation.

fanok.factor_model.factor_model.randomized_subspace_iteration(A_dot_v, p: int, rank: int, q: int)

For a real symmetric p*p matrix A, computes a low-rank p*r matrix Q whose range approximates the one of A.

Parameters:
  • A_dot_v – Callable taking a matrix and returning its product with A
  • p – Size of the matrix A
  • rank – Rank of Q
  • q – Number of iterations to perform
fanok.factor_model.factor_model.randomized_symmetric_decomposition(A_dot_v, p: int, rank: int, q: int, over_sample: int = 10)

For a real symmetric matrix A, computes its eigenvalue decomposition with randomized algorithms.

Parameters:
  • A_dot_v – Callable taking a matrix and returning its product with A
  • p – Size of the matrix A
  • rank – Rank of Q
  • q – Number of iterations to perform
  • over_sample – How many more vectors than the rank to use

for the low-rank approximation. This is essentialy usefull for stability purposes when the rank is low. Defaults to 10.

fanok.factor_model.factor_model.single_step_factor_model(X: numpy.ndarray, rank: int, mode: str = 'ledoit')
Parameters:
  • X – Data samples
  • rank – Rank approximation

Module contents