Skip to content
项目

关于

All Relevant Feature Selection

人工智能与机器学习

这些数字如何统计

实测星标增长

24小时
0
7天
正在收集历史
15天
正在收集历史
1个月
正在收集历史

各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。

README.md

原文

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.

探索相关项目

加载中…