Skip to content
Projects

About

All Relevant Feature Selection

AI & Machine Learning

How these counts are measured

Measured star growth

in 24h
Collecting history
in 7 days
Collecting history
in 15 days
Collecting history
in 1 month
Collecting history

Net star changes over overlapping periods, not daily totals. Missing measurements are left blank. Stars measure attention, not software quality.

README.md

Original

ARFS feature selection

ARFS logo

Web documentation · PyPI · Downloads · Support ARFS on Ko-fi

Installation

Add ARFS to a uv project that supports Python 3.9–3.12.

uv add arfs

If you use pip, run this in your Python environment.

python -m pip install arfs

The examples below use ARFS 5.0.1. If PyPI still offers an older version, install the 5.0.1 release wheel.

python -m pip install https://github.com/ThomasBury/arfs/releases/download/5.0.1/arfs-5.0.1-py3-none-any.whl

First fit with GrootCV

This offline example uses one strong predictor and two noise columns. Split the rows before fitting so selection sees only the training data.

import numpy as np
import pandas as pd
from sklearn.model_selection import train_test_split

from arfs.feature_selection import GrootCV

rng = np.random.default_rng(42)
X = pd.DataFrame(rng.normal(size=(240, 3)), columns=["signal", "noise_a", "noise_b"])
y = 5 * X["signal"] + rng.normal(scale=0.1, size=len(X))
X_train, X_test, y_train, y_test = train_test_split(
    X, y, test_size=0.25, random_state=42
)

selector = GrootCV(
    objective="rmse",
    n_folds=3,
    n_iter=1,
    n_jobs=1,
    random_state=42,
    lgbm_params={"num_iterations": 40},
).fit(X_train, y_train)

X_train_selected = selector.transform(X_train)
X_test_selected = selector.transform(X_test)

print(selector.selected_features_.tolist())  # ['signal']
print(X_train_selected.shape, X_test_selected.shape)  # (180, 1) (60, 1)

GrootCV uses LightGBM to compare each predictor's importance with shuffled copies of the predictors. The selected columns depend on the data, the model and the training split. Use the held-out rows to evaluate a downstream model after selection.

Start with the method chooser to pick a selector for your task. See Upgrading to 5.0 for migration steps and the contributor guide to run the tutorials and build the docs.

Tutorials

Advanced tutorials

Method origins

Leshy builds on Boruta and BorutaPy. BoostAGroota builds on BoostARoota. GrootCV compares LightGBM SHAP contributions across folds. Methods overview describes how ARFS implements these methods, MRMR and Lasso.

Explore related projects

Loading…