randomized.modelQ¶
Module: randomized.modelQ
¶
Inheritance diagram for selectinf.randomized.modelQ
:
modelQ
¶
-
class
selectinf.randomized.modelQ.
modelQ
(Q, X, y, feature_weights, ridge_term=None, randomizer_scale=None, perturb=None)[source]¶ Bases:
selectinf.randomized.query.gaussian_query
A class for the randomized LASSO for post-selection inference. The problem solved is
\[\text{minimize}_{\beta} -X^Ty + \frac{1}{2} \beta^TQ\beta + \sum_{i=1}^p \lambda_i |\beta_i\| - \omega^T\beta + \frac{\epsilon}{2} \|\beta\|^2_2\]where \(\lambda\) is lam, \(\omega\) is a randomization generated below and the last term is a small ridge penalty. Each static method forms \(\ell\) as well as the \(\ell_1\) penalty. The generic class forms the remaining two terms in the objective.
-
__init__
(Q, X, y, feature_weights, ridge_term=None, randomizer_scale=None, perturb=None)[source]¶ Create a new post-selection object for the LASSO problem
- Parameters
loglike : regreg.smooth.glm.glm
A (negative) log-likelihood as implemented in regreg.
feature_weights : np.ndarray
Feature weights for L-1 penalty. If a float, it is brodcast to all features.
ridge_term : float
How big a ridge term to add?
randomizer_scale : float
Scale for IID components of randomization.
perturb : np.ndarray
Random perturbation subtracted as a linear term in the objective function.
-
fit
(solve_args={'min_its': 50, 'tol': 1e-12}, perturb=None)[source]¶ Fit the randomized lasso using regreg.
- Parameters
solve_args : keyword args
Passed to regreg.problems.simple_problem.solve.
- Returns
signs : np.float
Support and non-zero signs of randomized lasso solution.
-
summary
(target='selected', features=None, parameter=None, level=0.9, ndraw=10000, burnin=2000, compute_intervals=False, dispersion=None)[source]¶ Produce p-values and confidence intervals for targets of model including selected features
- Parameters
target : one of [‘selected’, ‘full’]
features : np.bool
Binary encoding of which features to use in final model and targets.
parameter : np.array
Hypothesized value for parameter – defaults to 0.
level : float
Confidence level.
ndraw : int (optional)
Defaults to 1000.
burnin : int (optional)
Defaults to 1000.
compute_intervals : bool
Compute confidence intervals?
dispersion : float (optional)
Use a known value for dispersion, or Pearson’s X^2?
-
selective_MLE
(target='selected', features=None, parameter=None, level=0.9, compute_intervals=False, dispersion=None, solve_args={'tol': 1e-12})[source]¶ - Parameters
target : one of [‘selected’, ‘full’]
features : np.bool
Binary encoding of which features to use in final model and targets.
parameter : np.array
Hypothesized value for parameter – defaults to 0.
level : float
Confidence level.
ndraw : int (optional)
Defaults to 1000.
burnin : int (optional)
Defaults to 1000.
compute_intervals : bool
Compute confidence intervals?
dispersion : float (optional)
Use a known value for dispersion, or Pearson’s X^2?
-
get_sampler
()¶
-
randomize
(perturb=None)¶ The actual randomization step.
- Parameters
perturb : ndarray, optional
Value of randomization vector, an instance of \(\omega\).
-
property
sampler
¶ Sampler of optimization (augmented) variables.
-
set_sampler
(sampler)¶
-
setup_sampler
()¶ Setup query to prepare for sampling. Should set a few key attributes:
observed_score_state
observed_opt_state
opt_transform
-
solve
()¶
-
useC
= True¶
-