okridge.solvers

Module Contents

Classes

linRegModel_unnormalized_big_n

sparseLogRegModel_big_n

Functions

total_size(o[, handlers, verbose])

Returns the approximate memory footprint an object and all of its contents.

calculate_size(tmp_dict)

okridge.solvers.total_size(o, handlers={}, verbose=False)

Returns the approximate memory footprint an object and all of its contents.

Automatically finds the contents of the following builtin containers and their subclasses: tuple, list, deque, dict, set and frozenset. To search other containers, add handlers to iterate over their contents:

handlers = {SomeContainerClass: iter,

OtherContainerClass: OtherContainerClass.get_elements}

okridge.solvers.calculate_size(tmp_dict)
class okridge.solvers.linRegModel_unnormalized_big_n(data)
warm_start_from_betas(betas)

Warm start the model from a given betas

Parameters:

betas (np.array) – 1D array of coefficients

get_betas()

Get the current betas

Returns:

1D array of coefficients

Return type:

np.array

get_betas_r()

Get the current betas, and r

Returns:

1D array of coefficients np.array: 1D array of intermediate values - XTX_lambda2.dot(betas)

Return type:

np.array

get_betas_r_loss()

Get the current betas, r, and loss

Returns:

1D array of coefficients np.array: 1D array of intermediate values - XTX_lambda2.dot(betas) float: loss

Return type:

np.array

finetune_on_current_support(supp_mask)

Finetune the current solution on a given support

Parameters:

supp_mask (np.array) – 1D array of boolean values indicating the support

Returns:

1D array of coefficients on the support np.array: 1D array of intermediate values - XTX_lambda2.dot(betas) float: loss

Return type:

np.array

class okridge.solvers.sparseLogRegModel_big_n(data, parent_size=10, child_size=10, allowed_supp_mask=None, max_memory_GB=50)

Bases: linRegModel_unnormalized_big_n

reset_fixed_supp_and_allowed_supp(fixed_supp_mask, allowed_supp_mask)

Reset the fixed support and allowed support

Parameters:
  • fixed_supp_mask (np.array) – 1D array of boolean values indicating the fixed support

  • allowed_supp_mask (np.array) – 1D array of boolean values indicating the allowed support

get_sparse_sol_via_brute_force(k)

Get sparse solution through brute force

Parameters:

k (int) – cardinality of the final sparse solution

get_sparse_sol_via_OMP(k)

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) – cardinality of the final sparse solution

beamSearch_multipleSupports_via_OMP_by_1()

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.

expand_parent_i_support_via_OMP_by_1(i)

For parent solution i, generate [child_size] child solutions

Parameters:

i (int) – index of the parent solution