Skip to main content

mSFFS feature selection with a functional API and sklearn-compatible transformer

Project description

mSFFS

mSFFS (Modified Sequential Floating Forward Selection) is a Python library for feature selection, offering a simple functional API and a scikit-learn–compatible transformer.

Install

pip install msffs

Minimal usage (defaults)

import numpy as np
from msffs import msffs_select

X = np.array(
    [
        [0.1, 0.2, 0.3, 0.4],
        [0.2, 0.1, 0.4, 0.3],
        [0.15, 0.25, 0.35, 0.45],
        [0.9, 0.8, 0.7, 0.6],
        [0.8, 0.9, 0.6, 0.7],
        [0.85, 0.75, 0.65, 0.55],
    ]
)
y = np.array([0, 0, 0, 1, 1, 1])

result = msffs_select(X, k=2, y=y)
print(result["selected_indices"])

Scikit-learn pipeline usage

from sklearn.pipeline import Pipeline
from sklearn.preprocessing import StandardScaler
from sklearn.svm import SVC
from msffs import MSFFSSelector

pipe = Pipeline(
    steps=[
        ("scale", StandardScaler()),
        (
            "select",
            MSFFSSelector(
                k=2,
                estimator=SVC(),
                grid_params={"param_grid": {"C": [1.0], "kernel": ["linear"]}, "cv": 2},
            ),
        ),
    ]
)

X_selected = pipe.fit_transform(X, y)

API overview

  • msffs_select(X, k, y, estimator=None, grid_params=None) returns a dict with:
    • selected_indices: indices of the selected features
    • selected_X: X subset to selected features (when available)
    • best_scores: cross-validated scores by subset size
    • winner_list: selected feature indices by subset size
    • best_params_list: best estimator params by subset size
  • MSFFSSelector: scikit-learn compatible transformer for pipelines.

Defaults:

  • Estimator: sklearn.linear_model.LogisticRegression(max_iter=1000, random_state=0)
  • Grid params:
    • C: [0.1, 1.0, 10.0]
    • cv: 3

Notes

  • mSFFS is supervised, so y is required.
  • For very small datasets, reduce CV folds via grid_params={"cv": 2, ...}.
  • Defaults stay lightweight and deterministic; pass any sklearn-compatible estimator when you need something heavier (e.g., XGBoost).

Development

pip install -e ".[dev,test]"
ruff check .
black --check .
pytest
python -m build

Citation

If you use this library in academic work, please cite:

  • J. Li, D. De Ridder, D. Adhia, M. Hall, R. Mani and J. D. Deng, "Modified Feature Selection for Improved Classification of Resting-State Raw EEG Signals in Chronic Knee Pain," in IEEE Transactions on Biomedical Engineering, vol. 72, no. 5, pp. 1688-1696, May 2025, doi: 10.1109/TBME.2024.3517659.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

msffs-0.1.0.tar.gz (9.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

msffs-0.1.0-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

Details for the file msffs-0.1.0.tar.gz.

File metadata

  • Download URL: msffs-0.1.0.tar.gz
  • Upload date:
  • Size: 9.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for msffs-0.1.0.tar.gz
Algorithm Hash digest
SHA256 bf88050a83abd5017acac0e5b4bb81c20f887c47b85e8f6831589e4010f92d2f
MD5 d1214de1ee09f16b51c78cc0a521445c
BLAKE2b-256 86d4ab4badafdde6fc068057015ebf4ab0218c4650b09bc1c0d22d87d88c483d

See more details on using hashes here.

File details

Details for the file msffs-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: msffs-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for msffs-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4fad39bea51877ef0d647f6a03aaf1a28c662c663738d7e59f0ae9db34972dcd
MD5 19833ecac50d002a5ece592d7ad5d8d6
BLAKE2b-256 06986310a3aa7bfb86472fdedb1042749688b872e78fa2d0d1b9be1f9c90bb51

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page