Bits & Flames bitsandflames/fyron

Feature Selection

fyron.feature_selection provides transparent feature-selection strategies for clinical data science. It is designed for model development notebooks where every selection decision should be inspectable and reportable.

Install

bash
uv add "fyron[feature-selection]"

Imports

python
from fyron import feature_selection as fs

Function Reference

FunctionRequiredOptionalReturns
univariate_feature_screening(X, y, ...)feature table, targettask, alpha, FDR correctionselected features and screening table
variance_filter(X, ...)feature tablevariance thresholdselected features and variance table
correlation_filter(X, ...)feature tablethreshold, methodselected/dropped features and correlation pairs
model_importance_selection(estimator, X, y, ...)estimator, features, targetthreshold or top Nimportance table and fitted model
permutation_importance_selection(estimator, X, y, ...)estimator, features, targetrepeats, scoring, threshold/top Npermutation importance table
boruta_feature_selection(X, y, ...)features, targetBoruta/sklearn optionsBoruta ranking table
stability_selection(estimator, X, y, ...)estimator, features, targetrounds, sample fraction, thresholdselection-frequency table
combine_feature_selection_results(results, ...)result dictionariesstrategy, minimum methodsconsensus table

Example

python
from sklearn.ensemble import RandomForestClassifier
from fyron import feature_selection as fs

univariate = fs.univariate_feature_screening(
    X,
    y,
    task="classification",
    alpha=0.05,
)

correlation = fs.correlation_filter(
    X,
    threshold=0.85,
    method="spearman",
)

stable = fs.stability_selection(
    RandomForestClassifier(n_estimators=300, random_state=42),
    X[correlation["selected_features"]],
    y,
    n_rounds=100,
    selection_threshold=0.6,
)

final = fs.combine_feature_selection_results(
    {
        "univariate": univariate,
        "correlation": correlation,
        "stability": stable,
    },
    strategy="consensus",
    min_methods=2,
)

final["selected_features"]
final["summary_table"]

Interpretation

Feature selection is a model-development tool, not causal evidence. Use the returned tables to document why a feature was kept or dropped, and validate the final feature set on held-out or external data when possible.