fasterrisk.sparseBeamSearch

Classes

sparseLogRegModel

groupSparseLogRegModel

Module Contents

class fasterrisk.sparseBeamSearch.sparseLogRegModel(X, y, lambda2=1e-08, intercept=True, original_lb=-5, original_ub=5)

Bases: fasterrisk.base_model.logRegModel

getAvailableIndices_for_expansion(betas)

Get the indices of features that can be added to the support of the current sparse solution

Parameters:

betas (ndarray) – (1D array with float type) The current sparse solution

Returns:

available_indices – (1D array with int type) The indices of features that can be added to the support of the current sparse solution

Return type:

ndarray

expand_parent_i_support_via_OMP_by_1(i, child_size=10)

For parent solution i, generate [child_size] child solutions

Parameters:
  • i (int) – index of the parent solution

  • child_size (int, optional) – how many child solutions to generate based on parent solution i, by default 10

beamSearch_multipleSupports_via_OMP_by_1(parent_size=10, child_size=10)

Each parent solution generates [child_size] child solutions, so there will be [parent_size] * [child_size] number of total child solutions. However, only the top [parent_size] child solutions are retained as parent solutions for the next level i+1.

Parameters:
  • parent_size (int, optional) – how many top solutions to retain at each level, by default 10

  • child_size (int, optional) – how many child solutions to generate based on each parent solution, by default 10

get_sparse_sol_via_OMP(k, parent_size=10, child_size=10)

Get sparse solution through beam search and orthogonal matching pursuit (OMP), for level i, each parent solution generates [child_size] child solutions, so there will be [parent_size] * [child_size] number of total child solutions. However, only the top [parent_size] child solutions are retained as parent solutions for the next level i+1.

Parameters:
  • k (int) – number of nonzero coefficients for the final sparse solution

  • parent_size (int, optional) – how many top solutions to retain at each level, by default 10

  • child_size (int, optional) – how many child solutions to generate based on each parent solution, by default 10

class fasterrisk.sparseBeamSearch.groupSparseLogRegModel(X, y, lambda2=1e-08, intercept=True, original_lb=-5, original_ub=5, group_sparsity=10, featureIndex_to_groupIndex=None, groupIndex_to_featureIndices=None)

Bases: sparseLogRegModel

group_sparsity
featureIndex_to_groupIndex
groupIndex_to_featureIndices
getAvailableIndices_for_expansion(betas)

Get the indices of features that can be added to the support of the current sparse solution

Parameters:

betas (ndarray) – (1D array with float type) The current sparse solution

Returns:

available_indices – (1D array with int type) The indices of features that can be added to the support of the current sparse solution

Return type:

ndarray