fasterrisk.rounding

Classes

starRaySearchModel

Module Contents

class fasterrisk.rounding.starRaySearchModel(X, y, lb=-5, ub=5, num_ray_search=20, early_stop_tolerance=0.001)
X
y
yX
n
p
early_stop_tolerance

Get an array of multipliers to try for line search

Parameters:

betas (ndarray) – (1D array with float type) a given solution with shape = (1+p, ) assuming the first entry is the intercept

Returns:

multipliers – (1D array with float type) an array of candidate multipliers with shape = (num_ray_search, )

Return type:

ndarray

star_ray_search_scale_and_round(sparseDiversePool_beta0_continuous, sparseDiversePool_betas_continuous)

For each continuous solution in the sparse diverse pool, find the best multiplier and integer solution. Return the best integer solutions and the corresponding multipliers in the sparse diverse pool

Parameters:
  • sparseDiversePool_beta_continuous (ndarray) – (1D array with float type) an array of continuous intercept with shape = (m, )

  • sparseDiversePool_betas_continuous (ndarray) – (2D array with float type) an array of continuous coefficients with shape = (m, p)

Returns:

  • multipliers (ndarray) – (1D array with float type) best multiplier for each continuous solution with shape = (m, )

  • best_beta0 (ndarray) – (1D array with float type) best integer intercept for each continuous solution with shape = (m, )

  • best_betas (ndarray) – (2D array with float type) best integer coefficient for each continuous solution with shape = (m, p)

line_search_scale_and_round(betas)

For a given solution betas, multiply the solution with different multipliers and round each scaled solution to integers. Return the best integer solution based on the logistic loss.

Parameters:

betas (ndarray) – (1D array with float type) a given solution with shape = (1+p, ) assuming the first entry is the intercept

Returns:

  • best_multiplier (float) – best multiplier among all pairs of (multiplier, integer_solution)

  • best_betas (ndarray) – (1D array with float type) best integer solution among all pairs of (multiplier, integer_solution)

get_rounding_distance_and_dimension(betas)

For each dimension, get distances from the real coefficient to the rounded-up integer and the rounded-down integer

Parameters:

betas (ndarray) – (1D array with float type) current continuous (real-valued) solution

Returns:

  • betas_floor (ndarray) – (1D array with float type) rounded-down coefficients

  • dist_from_start_to_floor (ndarray) – (1D array with float type) distance from the real coefficient to the rounded-down integer

  • betas_ceil (ndarray) – (1D array with float type) rounded-up coefficients

  • dist_from_start_to_ceil (ndarray) – (1D array with float type) distance from the real coefficient to the rounded-up integer

  • dimensions_to_round (int[:]) – array of indices where the coefficients are not integers to begin with and upon which we should do rounding

auxilliary_rounding(betas, yX)

Round the solutions to intgers according to the auxilliary loss proposed in the paper

Parameters:
  • betas (ndarray) – (1D array with float type) current continuous (real-valued) solution

  • yX (ndarray) – (2D array with float type) yX[i, j] = y[i] * X[i, j]

Returns:

integer_beta – (1D array with float type) rounded integer solution

Return type:

ndarray