ddn3.solver

Wrapper functions for calling the BCD algorithms

Module Contents

Functions

run_org(g1_data, g2_data, node, lambda1, lambda2, ...)

The wrapper that calls the DDN 2.0 BCD algorithm

run_resi(g1_data, g2_data, node, lambda1, lambda2, ...)

The wrapper that calls the DDN 3.0 residual update algorithm

run_corr(corr_matrix_1, corr_matrix_2, node, lambda1, ...)

The wrapper that calls the DDN 3.0 correlation matrix update algorithm

run_strongrule(g1_data, g2_data, node, lambda1, ...[, ...])

The wrapper that calls the DDN 3.0 strong rule strategy.

ddn3.solver.run_org(g1_data, g2_data, node, lambda1, lambda2, beta1_in, beta2_in, threshold=1e-06, use_warm=False)

The wrapper that calls the DDN 2.0 BCD algorithm

Denote P be the number features. N1 be the sample size for condition 1, and N2 for condition 2.

Parameters:
  • g1_data (array_like, shape N1 by P) – The data from condition 1

  • g2_data (array_like, shape N2 by P) – The data from condition 2

  • node (int) – Index of the current node that serve as the response variable.

  • lambda1 (float) – DDN parameter lambda1.

  • lambda2 (float) – DDN parameter lambda2.

  • beta1_in (array_like, length P) – Initial beta for condition 1. If initialization is not needed, use an array of all zeros.

  • beta2_in (array_like, length P) – Initial beta for condition 2. If initialization is not needed, use an array of all zeros.

  • threshold (float) – Convergence threshold.

  • use_warm (bool, optional) – Not used. To use warm start, simply input beta1_in and beta2_in from previous hyperparameters.

Returns:

  • beta1 (ndarray, length P) – Estimated beta for node in condition 1.

  • beta2 (ndarray, length P) – Estimated beta for node in condition 2.

ddn3.solver.run_resi(g1_data, g2_data, node, lambda1, lambda2, beta1_in, beta2_in, threshold, use_warm=False)

The wrapper that calls the DDN 3.0 residual update algorithm

If warm start is used, the residual signal is updated accordingly to previously estimated beta. This takes some extra time, and may make warm start less appealing.

Denote P be the number features. N1 be the sample size for condition 1, and N2 for condition 2.

Parameters:
  • g1_data (array_like, shape N1 by P) – The data from condition 1

  • g2_data (array_like, shape N2 by P) – The data from condition 2

  • node (int) – Index of the current node that serve as the response variable.

  • lambda1 (float) – DDN parameter lambda1.

  • lambda2 (float) – DDN parameter lambda2.

  • beta1_in (array_like, length P) – Initial beta for condition 1. If initialization is not needed, use an array of all zeros.

  • beta2_in (array_like, length P) – Initial beta for condition 2. If initialization is not needed, use an array of all zeros.

  • threshold (float) – Convergence threshold.

  • use_warm (bool, optional) – If true, use warm start.

Returns:

  • beta1 (ndarray, length P) – Estimated beta for node in condition 1.

  • beta2 (ndarray, length P) – Estimated beta for node in condition 2.

ddn3.solver.run_corr(corr_matrix_1, corr_matrix_2, node, lambda1, lambda2, beta1_in, beta2_in, threshold, use_warm=False)

The wrapper that calls the DDN 3.0 correlation matrix update algorithm

Parameters:
  • corr_matrix_1 (ndarray) – Input correlation matrix for condition 1.

  • corr_matrix_2 (ndarray) – Input correlation matrix for condition 2.

  • node (int) – Index of the current node that serve as the response variable.

  • lambda1 (float) – DDN parameter lambda1.

  • lambda2 (float) – DDN parameter lambda2.

  • beta1_in (array_like, length P) – Initial beta for condition 1. If initialization is not needed, use an array of all zeros.

  • beta2_in (array_like, length P) – Initial beta for condition 2. If initialization is not needed, use an array of all zeros.

  • threshold (float) – Convergence threshold.

  • use_warm (bool, optional) – If true, use warm start.

Returns:

  • beta1 (ndarray, length P) – Estimated beta for node in condition 1.

  • beta2 (ndarray, length P) – Estimated beta for node in condition 2.

ddn3.solver.run_strongrule(g1_data, g2_data, node, lambda1, lambda2, beta1_in, beta2_in, threshold, use_warm=False)

The wrapper that calls the DDN 3.0 strong rule strategy.

In this algorithm, lambda2 is kept as zero. Then DDN becomes two separate lasso problem. The strong rule can then be utilized to eliminate part of the predictor variables for each lambda1. The lasso problem is also solved by the lasso function of scikit-learn.

Warm start is generally preferred when using this strategy.

Note that empirically this strategy is not fast.

Denote P be the number features. N1 be the sample size for condition 1, and N2 for condition 2.

Parameters:
  • g1_data (array_like, shape N1 by P) – The data from condition 1

  • g2_data (array_like, shape N2 by P) – The data from condition 2

  • node (int) – Index of the current node that serve as the response variable.

  • lambda1 (float) – DDN parameter lambda1.

  • lambda2 (float) – Not used. Must be 0.

  • beta1_in (array_like, length P) – Initial beta for condition 1. If initialization is not needed, use an array of all zeros.

  • beta2_in (array_like, length P) – Initial beta for condition 2. If initialization is not needed, use an array of all zeros.

  • threshold (float) – Convergence threshold.

  • use_warm (bool, optional) – Use warm start or not.

Returns:

  • beta1 (ndarray, length P) – Estimated beta for node in condition 1.

  • beta2 (ndarray, length P) – Estimated beta for node in condition 2.