fasterrisk.sparseDiversePool

Classes

sparseDiversePoolLogRegModel

groupSparseDiversePoolLogRegModel

Module Contents

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

Bases: fasterrisk.base_model.logRegModel

getAvailableIndices_for_expansion_but_avoid_l(nonsupport, support, l)

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

get_sparseDiversePool(gap_tolerance=0.05, select_top_m=10, maxAttempts=50)

For the current sparse solution, get from the sparse diverse pool [select_top_m] solutions, which perform equally well as the current sparse solution. This sparse diverse pool is also called the Rashomon set. We discover new solutions by swapping 1 feature in the support of the current sparse solution.

Parameters:
  • gap_tolerance (float, optional) – New solution is accepted after swapping features if the new loss is within the [gap_tolerance] of the old loss, by default 0.05

  • select_top_m (int, optional) – We select the top [select_top_m] solutions from support_size*maxAttempts number of new solutions, by default 10

  • maxAttempts (int, optional) – We try to swap each feature in the support with [maxAttempts] of new features, by default 50

Returns:

  • intercept_array (ndarray) – (1D array with float type) Return the intercept array with shape = (select_top_m, )

  • coefficients_array (ndarray) – (2D array with float type) Return the coefficients array with shape = (select_top_m, p)

class fasterrisk.sparseDiversePool.groupSparseDiversePoolLogRegModel(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: sparseDiversePoolLogRegModel

group_sparsity
featureIndex_to_groupIndex
groupIndex_to_featureIndices
getAvailableIndices_for_expansion_but_avoid_l(nonsupport, support, l)

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

Parameters:
  • nonsupport (ndarray) – (1D array with int type) The indices of features that are not in the support of the current sparse solution

  • support (ndarray) – (1D array with int type) The indices of features that are in the support of the current sparse solution

  • l (int) – The index of the feature that is to be removed from the support of the current sparse solution and this index l belongs to support

Returns:

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

Return type:

ndarray