GaussianKnockoffs#
- class hidimstat.samplers.GaussianKnockoffs(cov_estimator=None, tol=1e-14)[source]#
Bases:
BaseEstimatorGenerator for second-order Gaussian variables using the equi-correlated method. Creates synthetic variables that preserve the covariance structure of the original variables while ensuring conditional independence between the original and synthetic data.
- Parameters:
- cov_estimatorobject
Estimator for computing the covariance matrix. Must implement fit and have a covariance_ attribute after fitting.
- tolfloat, default=1e-14
Tolerance threshold. While the smallest eigenvalue of \(2\Sigma - diag(S)\) is smaller than this threshold, S is incrementally increased.
- Attributes:
- mu_tilde_ndarray of shape (n_samples, n_features)
Mean matrix for generating synthetic variables.
- sigma_tilde_decompose_ndarray of shape (n_features, n_features)
Cholesky decomposition of the synthetic covariance matrix.
References
- fit(X, y=None)[source]#
Fit the Gaussian synthetic variable generator. This method estimates the parameters needed to generate Gaussian synthetic variables based on the input data. It follows a methodology for creating second-order synthetic variables that preserve the covariance structure.
- Parameters:
- Xarray-like of shape (n_samples, n_features)
The input samples used to estimate the parameters for synthetic variable generation. The data is assumed to follow a Gaussian distribution.
- yIgnored
This parameter is not used, but is included for compatibility with scikit-learn’s API.
- Returns:
- selfobject
Returns the instance itself.
Notes
The method implements the following steps: 1. Centers and scales the data if specified 2. Estimates mean and covariance of input data 3. Computes parameters for synthetic variable generation
- sample(n_repeats: int = 1, random_state=None)[source]#
Generate synthetic variables. This function generates synthetic variables that preserve the covariance structure of the original data while ensuring conditional independence.
- Parameters:
- n_repeatsint, default=1
The number of sets of Gaussian knockoff variables
- random_stateint or None, default=None
The random state to use for sampling.
- Returns:
- X_tilde3D ndarray (n_repeats, n_samples, n_features)
The synthetic variables.
- get_metadata_routing()[source]#
Get metadata routing of this object.
Please check User Guide on how the routing mechanism works.
- Returns:
- routingMetadataRequest
A
MetadataRequestencapsulating routing information.
- get_params(deep=True)[source]#
Get parameters for this estimator.
- Parameters:
- deepbool, default=True
If True, will return the parameters for this estimator and contained subobjects that are estimators.
- Returns:
- paramsdict
Parameter names mapped to their values.
- set_params(**params)[source]#
Set the parameters of this estimator.
The method works on simple estimators as well as on nested objects (such as
Pipeline). The latter have parameters of the form<component>__<parameter>so that it’s possible to update each component of a nested object.- Parameters:
- **paramsdict
Estimator parameters.
- Returns:
- selfestimator instance
Estimator instance.
Examples using hidimstat.samplers.GaussianKnockoffs#
Controlled multiple variable selection on the Wisconsin breast cancer dataset