Getting started¶
To illustrate the algorithm in this package, simulated data will be used. Functionality to create simulated matrix layouts is provided.
In [ ]:
Copied!
from numpy.random import default_rng
from sklearn import set_config
import solrcmf
set_config(display="text") # show text representation of sklearn estimators
# Control randomness
rng = default_rng(42)
# The function below generates sparse orthogonal matrices V_i and uses the
# supplied D_ij to form signal matrices V_i D_ij V_j^T. Noise with
# residual variance controlled by the signal-to-noise ratio is added.
xs_sim = solrcmf.simulate(
viewdims={0: 100, 1: 50, 2: 50},
factor_scales={
(0, 1): [7.0, 5.1, 4.6, 0.0, 0.0],
(0, 2): [8.3, 0.0, 0.0, 5.5, 0.0],
(1, 2, 0): [6.3, 0.0, 4.7, 0.0, 5.1],
(1, 2, 1): [0.0, 8.6, 4.9, 0.0, 0.0],
},
factor_sparsity={0: 0.25, 1: 0.25, 2: 0.25},
snr=0.5,
rng=rng,
)
# `xs_sim` is a dictionary containing
# - "xs_truth", the true signal matrices
# - "xs", the noisy data
# - "vs", the simulated orthogonal factors
from numpy.random import default_rng
from sklearn import set_config
import solrcmf
set_config(display="text") # show text representation of sklearn estimators
# Control randomness
rng = default_rng(42)
# The function below generates sparse orthogonal matrices V_i and uses the
# supplied D_ij to form signal matrices V_i D_ij V_j^T. Noise with
# residual variance controlled by the signal-to-noise ratio is added.
xs_sim = solrcmf.simulate(
viewdims={0: 100, 1: 50, 2: 50},
factor_scales={
(0, 1): [7.0, 5.1, 4.6, 0.0, 0.0],
(0, 2): [8.3, 0.0, 0.0, 5.5, 0.0],
(1, 2, 0): [6.3, 0.0, 4.7, 0.0, 5.1],
(1, 2, 1): [0.0, 8.6, 4.9, 0.0, 0.0],
},
factor_sparsity={0: 0.25, 1: 0.25, 2: 0.25},
snr=0.5,
rng=rng,
)
# `xs_sim` is a dictionary containing
# - "xs_truth", the true signal matrices
# - "xs", the noisy data
# - "vs", the simulated orthogonal factors
In [ ]:
Copied!