Python implementation of integrated path stability selection (IPSS)
Project description
Integrated path stability selection (IPSS)
Integrated path stability selection (IPSS) is a general method for improving feature selection algorithms. Given an n-by-p data matrix X (n = number of samples, p = number of features), and an n-dimensional response variable y, IPSS applies a base selection algorithm to subsamples of the data to select features (columns of X) that are most related to y. This package includes IPSS for gradient boosting (IPSSGB), random forests (IPSSRF), and L1-regularized linear models (IPSSL). The final outputs are efp scores and q-values for each feature in X.
- The efp score of feature j is the expected number of false positives, E(FP), selected when j is selected.
- So to control the E(FP) at
target_fp, select the features with efp scores at mosttarget_fp.
- So to control the E(FP) at
- The q-value of feature j is the false discovery rate (FDR) when feature j is selected.
- So to control the FDR at
target_fdr, select the features with q-values at mosttarget_fdr.
- So to control the FDR at
Key attributes
- Error control: IPSS controls the number of false positives and the FDR.
- Generality: IPSSGB and IPSSRF are nonlinear, nonparametric methods. IPSSL is linear.
- Speed: IPSS is efficient. For example, IPSSGB runs in <20 seconds when
n = 500andp = 5000. - Simplicity: The only required inputs are
Xandy. Users can also specify the base method (IPSSGB, IPSSRF, or IPSSL), and the target number of false positives or the target FDR.
Associated papers
IPSSL: https://arxiv.org/abs/2403.15877
IPSSGB and IPSSRF: https://arxiv.org/abs/2410.02208v1
Installation
Install from PyPI:
pip install ipss
Tests
Basic test (test_basic.py)
- Run the test:
python3 test_basic.py
- Expected output: "All tests passed."
Ovarian cancer: microRNAs and tumor purity (test_oc.py)
- Identify microRNAs related to tumor purity in tumor samples from ovarian cancer patients
- Data are from LinkedOmics and located in
examples/cancer/ovarian - Run the test:
python3 test_oc.py
- Expected output: q-values and efp scores for top ranked microRNAs
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 number of false positives
target_fp = 1
efp_scores = ipss_output['efp_scores']
selected_features = [idx for idx, efp_score in efp_scores.items() if efp_score <= target_fp]
print(f'Selected features (target E(FP) = {target_fp}): {selected_features}')
# 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}')
Results
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: List of indices of features selected by IPSS; empty list iftarget_fpandtarget_fdrare not specified (list of ints).stability_paths: Estimated selection probabilities at each parameter value (array of shape(n_alphas, p))
Examples
Additional examples are available in the examples folder. These include
- A simple example,
simple_example.py(Open in Google Colab). - Various simulation experiments,
simulation.py(Open in Google Colab). - IPSS applied to 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 continuous or binary.
Optional arguments:
selector: Base algorithm to use (str; default'gb'). Options:'gb': Gradient boosting (uses XGBoost).'l1': L1-regularized linear or logistic regression (uses sci-kit learn).'rf': Random forest (uses sci-kit learn).
selector_args: Arguments for the base algorithm (dict; defaultNone).preselect: Preselect/filter features prior to subsampling (bool; defaultTrue).preselect_args: Arguments for preselection algorithm (dict; defaultNone).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; default100for IPSSGB,50otherwise).n_alphas: Number of values in the regularization or threshold grid (int; default15if'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; default1).standardize_X: Scale features to have mean 0, standard deviation 1 (bool; defaultNone).center_y: Center response to have mean 0 (bool; defaultNone).n_jobs: Number of jobs to run in parallel (int; default1).
General observations/recommendations:
- IPSSGB is usually best for capturing nonlinear relationships between features and response
- IPSSL is usually best for capturing linear relationships between features and response
target_fportarget_fdr(at most one is specified) are problem specific/left to the user- In general, all other parameters should not 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'h1'.- Preselection can significantly reduce computation time.
- Results are robust to
cutoffprovided it is between0.025and0.1. - Results are robust to
deltaprovided it is between0and1.5. - Standardization is automatically applied for IPSSL. IPSSGB and IPSSRF are unaffected by this.
- Centering
yis automatically applied for IPSSL. IPSSGB and IPSSRF are unaffected by this.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ipss-1.0.14.tar.gz.
File metadata
- Download URL: ipss-1.0.14.tar.gz
- Upload date:
- Size: 17.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
44ad965f16d29e305d62303d9a66f0af2855db5eb1d3dfa358971131259028ef
|
|
| MD5 |
aea62fb991fa70636aad5233da988687
|
|
| BLAKE2b-256 |
322e0681ffc3a53893686cd64cb0657be096f3d0faf4899f01b20289e9e0014e
|
File details
Details for the file ipss-1.0.14-py3-none-any.whl.
File metadata
- Download URL: ipss-1.0.14-py3-none-any.whl
- Upload date:
- Size: 12.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e208549e88c9778ee6a14a04cf30f9e83dbbf02d2b1ede74ca835b3261468243
|
|
| MD5 |
137a40cb484122d12a4c216792bbfd8e
|
|
| BLAKE2b-256 |
67027d350160fa2729bd3506614cc3d26a23db9d3550b1743184c8d5b4e5e116
|