Integrated path stability selection (IPSS)
Fast, flexible feature selection with false discovery control
Papers
-
Integrated path stability selection
Journal of the American Statistical Association • arXiv -
Nonparametric IPSS
Bioinformatics • arXiv
Installation
pip install ipss
Usage
from ipss import ipss
# load n-by-p feature matrix X and n-by-1 response vector y
# run ipss
ipss_output = ipss(X,y)
# select features based on target FDR
target_fdr = 0.1
q_values = ipss_output['q_values']
selected_features = [idx for idx, q_value in q_values.items() if q_value <= target_fdr]
print(f'Selected features (target FDR = {target_fdr}): {selected_features}')
Outputs
ipss_output = ipss(X,y) is a dictionary containing:
efp_scores: Dictionary whose keys are feature indices and values are their efp scores (dict of lengthp).q_values: Dictionary whose keys are feature indices and values are their q-values (dict of lengthp).runtime: Runtime of the algorithm in seconds (float).selected_features: Indices of features selected by IPSS; empty list iftarget_fpandtarget_fdrare not specified (list of ints).stability_paths: Estimated selection probabilities at each parameter (array of shape(n_alphas, p)).
Selecting features
Each feature (column of X) is assigned:
- a q-value: the minimum false discovery rate (FDR) at which the feature is selected
- an efp score: the minimum expected number of false positives (E(FP)) at which the feature is selected
To select features:
- Control FDR by choosing all features with
q_value ≤ target_fdr
Example: Selecting features withq_value ≤ 0.1controls the FDR at level 0.1 - Control E(FP) by choosing all features with
efp_score ≤ target_fp
Example: Selecting features withefp_score ≤ 2controls the E(FP) at level 2
Usage with custom feature importance scores
For custom feature importance scores, selector must be a function that takes X and y as inputs (as well as an optional
dictionary of arguments selector_args specific to the feature importance function), and returns a list or NumPy array of
importance scores, one per feature, that must align with the column order in X.
from ipss import ipss
# define custom feature importance function based on ridge regression
from sklearn.linear_model import Ridge
selector_args = {'alpha':1}
def ridge_selector(X, y, alpha):
model = Ridge(alpha=alpha)
model.fit(X,y)
feature_importance_scores = np.abs(model.coef_)
return feature_importance_scores
# load n-by-p feature matrix X and n-by-1 response vector y
# run ipss
ipss_output = ipss(X, y, selector=ridge_selector, selector_args=selector_args)
# select features based on target FDR
target_fdr = 0.1
q_values = ipss_output['q_values']
selected_features = [idx for idx, q_value in q_values.items() if q_value <= target_fdr]
print(f'Selected features (target FDR = {target_fdr}): {selected_features}')
Examples
The examples folder includes analyses of
- Simulated data:
simple_example.py(Open in Google Colab). - Cancer data:
cancer.py(Open in Google Colab).
Full list of ipss arguments
Required arguments:
X: Features (array of shape(n,p)), wherenis the number of samples andpis the number of features.y: Response (array of shape(n,)or(n, 1)).ipssautomatically detects ifyis binary.
Optional arguments:
selector: Base algorithm to use (str; default'gb').- Nonparametric methods
'gb': Gradient boosting (XGBoost).'rf': Random forest (scikit-learn).
- Penalized regression methods
'adaptive_lasso': Adaptive lasso (scikit-learn)'l1': L1-regularized linear or logistic regression (scikit-learn).
- Custom
- Users can provide their own feature importance function (see example above).
- Nonparametric methods
selector_args: Arguments for the base algorithm (dict; defaultNone).preselect: Preselect/filter features prior to subsampling (bool; defaultTrue).preselector: Method used to preselect features (defaultNone, which resolves to'dcor'for everyselectorexcept'l1'/'adaptive_lasso', which use their own linear preselection). Options:'gb': Gradient boosting (XGBoost) feature importances.'rf': Random forest (scikit-learn) feature importances.'l1'or'adaptive_lasso': (Adaptive) lasso/logistic regression coefficients.'dcor': Distance correlation. Captures nonlinear relationships and is fast and deterministic.- Custom: a function
preselector(X, y, **preselector_args) -> array of length pgiving a feature importance score per feature; the top-scoring features (seen_keepbelow) are kept.
preselector_args: Arguments for the preselection algorithm (dict; defaultNone). Recognized keys:n_runs: Number of times to refit the preselector, averaging feature importances across runs (int; default3; ignored by'dcor', which is deterministic).n_keep: Number of features to keep (int; defaults depend onpreselector).expansion_factor: For'gb'only, multiplies the number of features with nonzero importance to setn_keep(float; default1.5).engine: For'dcor'only (str; default'numpy').'numpy'computes distance correlation from scratch inO(n^2).'dcor'instead uses thedcorpackage's fasterO(n log n)algorithm, which scales better for largenbut requires installing thedcorextra (pip install ipss[dcor]orpip install dcor).
target_fp: Target number of false positives to control (positive float; defaultNone).target_fdr: Target false discovery rate (FDR) (positive float; defaultNone).B: Number of subsampling steps (int; default100ifselectoris'gb',50otherwise).n_alphas: Number of values in the regularization or threshold grid (int; default25if'l1'else100).ipss_function: Function to apply to selection probabilities (str; default'h2'if'l1'else'h3'). Options:'h1': Linear function,h1(x) = 2x - 1 if x >= 0.5 else 0.'h2': Quadratic function,h2(x) = (2x - 1)**2 if x >= 0.5 else 0.'h3': Cubic function,h3(x) = (2x - 1)**3 if x >= 0.5 else 0.
cutoff: Maximum value of the theoretical integral boundI(Lambda)(positive float; default0.05).delta: Defines probability measure; seeAssociated papers(float; defaults depend onselector).standardize_X: Scale features to have mean 0, standard deviation 1 (bool; defaultNone, which standardizes for'l1'and'adaptive_lasso'only).center_y: Center response to have mean 0 (bool; defaultNone, which centers for'l1'and'adaptive_lasso'only). Binary responses are never centered.n_jobs: Number of jobs to run in parallel (int; default1).
General observations/recommendations:
selector = 'gb'often best for capturing nonlinear relationships.selector = 'l1'or'adaptive_lasso'often best for capturing linear relationships.preselector = 'dcor'(the default for everyselectorexcept'l1'/'adaptive_lasso') captures nonlinearities and, unlike the model-based preselectors ('gb','rf','ufi'), is deterministic.- For FDR control, we generally recommend computing q-values with
ipssand then using them to select features at the desired FDR threshold, rather than specifyingtarget_fdr, which should be left asNone. This provides greater flexibility when selecting features. - For E(FP) control, we generally recommend computing efp scores with
ipssand then using them to select features at the desired false positive threshold, rather than specifyingtarget_fp, which should be left asNone. This provides greater flexibility when selecting features. - In general, all other parameters should not be changed
selector_argsinclude, e.g., decision tree parameters for tree-based models- Results are robust to
Bprovided it is greater than25 'h3'is less conservative than'h2'which is less conservative than'h1'.- Preselection can significantly reduce computation time and increase power.
- Results are robust to
cutoffprovided it is between0.025and0.1. - Features are automatically standardized for the penalized regression methods.
- The response is automatically centered for the regularized regression methods.
Metadata
Release files for ipss 1.1.13
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ipss-1.1.13.tar.gz | 19.9 kB | Without provenance | Details for ipss-1.1.13.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ipss-1.1.13-py3-none-any.whl | Python 3 | none | any | Details for ipss-1.1.13-py3-none-any.whl |
Total release size: 39.9 kB
Release files / ipss-1.1.13.tar.gz
| Download URL | ipss-1.1.13.tar.gz |
|---|---|
| Size | 19.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d8f525b1776ace93b011d5120cc79c24ce848eef6fd55fba4a8a6d742320e98b
|
|
BLAKE2b-256 checksum How to use checksums |
d8cc2a541e14a0c44c4ce5bd1a33e09bc04a8f5f8fad7aa586e2eb56aa6776d4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.7
|
Release files / ipss-1.1.13-py3-none-any.whl
| Download URL | ipss-1.1.13-py3-none-any.whl |
|---|---|
| Size | 20.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1dabe58bdc652611157ee21366c4e4e2e22fb5c382537e86efc168c2b4df6ea6
|
|
BLAKE2b-256 checksum How to use checksums |
022422e5a85b6b4502df2b2941278b605bb5c4bb9c6c35b580a60c95a9291008
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.7
|
Security for ipss 1.1.13
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.