collasso.simulate module#

Simulation.

Main function:

simulate - simulating feature and target matrices for multi-task learning

Examples#

>>> from collasso import CoopLassoCV
>>> x_train, y_train, x_test, y_test, beta = simulate()
>>> model = CoopLassoCV()
>>> model.fit(x_train, y_train)
>>> model.predict(x_test)
collasso.simulate.simulate(*, n0: int = 100, n1: int = 10000, p: int = 200, q: int = 3, rho: float = 0.9, kappa: float = 1.0, prob_com: float = 0.05, prob_sep: float = 0.05) tuple[ndarray, ndarray, ndarray, ndarray, ndarray]#

Simulate Data for Linear Multi-Task Regression.

Simulates feature matrix and target matrix, with given probabilities of (i) common effects on all targets and (ii) specific effects on one target.

Parameters:
n0int, default=100

Number of training samples.

n1int, default=10000

Number of testing samples.

pint, default=200

Number of features.

qint, default=3

Number of targets.

rhofloat, default=0.90

Correlation coefficient, 0<=rho<=1.

kappafloat, default=1.00

Correlation coefficient, 0<=kappa<=1.

prob_comfloat, default=0.05

Probability of common effects for all targets, 0<=prob_com<=1.

prob_sepfloat, default=0.05

Probability of separate effects for each target.

Returns:
x_trainndarray of shape (n0_samples,p_features) or (n0_samples,p_features,q_targets)

Training feature matrix or matrices, common matrix for all targets (if kappa=1) or separate matrix for each target (if 0<=kappa<1).

y_trainndarray of shape (n0_samples,q_targets)

Training target matrix.

x_testndarray of shape (n1_samples,p_features) or (n1_samples,p_features,q_targets)

Test feature matrix or matrices, common matrix for all targets (if kappa=1) or separate matrix for each target (if 0<=kappa<1).

y_testndarray of shape (n1_samples,q_targets)

Test target matrix.

betandarray of shape (p_features,q_targets)

True effects in the training and the test data (of the feature in the row on the target in the column).

Raises:
ValueError

See also

_simulate_features

Internal function for simulating feature matrix or matrices.

_simulate_effects

Internal function for simulating effect matrix.

_simulate_targets

Internal function for simulating target matrix.

Examples

>>> from collasso import simulate
>>> x_train, y_train, x_test, y_test, beta = simulate()