okridge.tree
Module Contents
Classes
- class okridge.tree.DataClass(X, y, lambda2)
- class okridge.tree.BNBTree(X, y, int_tol=0.0001, gap_tol=0.0001, lambda2=1e-05, max_memory_GB=300, useBruteForce=False, tighten_bound_via_ADMM=True)
- get_RAM_used_since_start()
- solve(k, gap_tol=0.01, number_of_dfs_levels=0, verbose=False, time_limit=3600)
Solve the k-sparse ridge regression problem using branch and bound
- Parameters:
k (int) – cardinality constraint
gap_tol (float, optional) – optimality gap tolerance hyperparameter. Defaults to 1e-2.
number_of_dfs_levels (int, optional) – number of levels for depth-first search during branch and bound. Defaults to 0.
verbose (bool, optional) – whether to print informations into terminal. Defaults to False.
time_limit (int, optional) – time limit (in seconds) of running branch and bound. Defaults to 3600.
- Returns:
cost or loss of the best solution found np.array: best solution found float: best gap found float: best lower bound found float: running time of branch and bound
- Return type:
float
- _solve_node(curr_node, k, dual_, upper_bound, tighten_bound_via_ADMM=True)
Solve the perspective relaxation of the node and update the dual bound
- Parameters:
curr_node (CustomClass) – current node to be solved
k (int) – cardinality constraint
dual (list) – list of minimum dual values at each depth of the tree
upper_bound (float) – current loss of the best solution found for this node
tighten_bound_via_ADMM (bool, optional) – whether to refine the dual bound computed by the Fast Solve method. Defaults to True.
- Returns:
dual value of the perspective relaxation of the current node
- Return type:
float
- solve_root(k, gap_tol=0.01, verbose=False)