Skip to main content

A Python package for automated feature selection in ML workflows.

Project description

๐Ÿ” AutoFeatureSelect

A lightweight, modular Python package for automatic feature selection in machine learning workflows.
It helps data scientists and ML engineers remove irrelevant, redundant, or noisy features to improve model performance, reduce overfitting, and simplify datasets โ€” without manual guesswork.


โœจ Why AutoFeatureSelect?

Most automated ML tools focus on feature generation, not feature elimination.

But throwing more features at a model often hurts performance. What if you want to cut the noise?

That's where AutoFeatureSelect shines:

  • โœ… Selects only the most relevant features
  • โœ… Works on any tabular dataset
  • โœ… No need to generate new features
  • โœ… Transparent, modular, and customizable
  • โœ… Compatible with any ML framework (scikit-learn, XGBoost, LightGBM, etc.)

๐Ÿš€ Installation

pip install smartfeatureselectml

๐Ÿ“ฆ What This Package Does

AutoFeatureSelect provides a growing set of feature selection tools, including:

Method Type Description
low_variance_filter Filter Removes features with very low variance (near-constant columns)
correlation_filter Filter Drops features that are highly correlated with others
mutual_info_filter Filter Selects features with high mutual information with target
vif_filter Filter Removes multicollinear features using Variance Inflation Factor
rfe_filter Wrapper Uses model-based recursive elimination of weakest features
tree_importance_filter Embedded Uses tree model importance scores for feature selection
shap_filter Embedded Uses SHAP values to rank and select top features

๐Ÿ“Œ Functions and Their Parameters

๐Ÿ”น filters.py

Function Parameters
correlation_filter df, target, threshold=0.9
low_variance_filter df, target=None, threshold=0.01
mutual_info_filter df, target, problem_type="classification", threshold=0.01
vif_filter df, target=None, threshold=5.0, verbose=True

๐Ÿ”น model_wrappers.py

Function Parameters
tree_importance_filter X, y, model=None, importance_threshold=0.01, top_n=None, verbose=True
rfe_filter X, y, model=None, n_features_to_select=10, verbose=True
shap_filter X, y, model=None, top_n=10, verbose=True

โœ… Notes

  • Only tree_importance_filter uses a threshold-like parameter, named importance_threshold.
  • rfe_filter uses n_features_to_select to define how many features to retain.
  • shap_filter uses top_n to keep the most impactful features based on SHAP values.

๐Ÿ”ง Example Usage

import pandas as pd
from sklearn.ensemble import RandomForestClassifier
from autofeatureselect.filters import (
    low_variance_filter,
    correlation_filter,
    mutual_info_filter,
    vif_filter
)
from autofeatureselect.model_wrappers import (
    tree_importance_filter,
    rfe_filter,
    shap_filter
)

# Load your dataset
df = pd.read_csv("data.csv")
target = "target_column"

# 1. Apply Low Variance Filter
df = low_variance_filter(df, threshold=0.01)

# 2. Apply Correlation Filter
df = correlation_filter(df, target=target, threshold=0.9)

# 3. Apply Mutual Information Filter
df = mutual_info_filter(df, target=target, problem_type="classification", threshold=0.01)

# 4. Apply VIF Filter
df = vif_filter(df, threshold=5.0)

# Separate features and target for model-based methods
X = df.drop(columns=[target])
y = df[target]

# 5. Apply Tree-Based Feature Importance
X = tree_importance_filter(X, y, model=RandomForestClassifier())

# 6. Apply RFE (Recursive Feature Elimination)
X = rfe_filter(X, y, model=RandomForestClassifier())

# 7. Apply SHAP-Based Selection
X = shap_filter(X, y, model=RandomForestClassifier())

# Combine X and y back
df_selected = pd.concat([X, y], axis=1)

# Final selected features
print(df_selected.head())

๐Ÿ’ก When to Use Which Method?

Method Best For Notes
low_variance_filter Removing constant or near-constant columns Fast and simple
correlation_filter Redundant features (highly correlated) Pairwise comparison
mutual_info_filter Non-linear relevance to target Requires problem_type parameter
vif_filter Multicollinearity Good before linear models
rfe_filter Model-driven selection Slower but accurate
tree_importance_filter Tree models (e.g. XGBoost, RandomForest) Uses feature importances from trees
shap_filter Global interpretability, model-agnostic Uses SHAP values, slower but insightful

๐Ÿ” How to Explore Available Functions

To explore the available feature selection functions and understand their parameters, you can use built-in Python tools in any Python environment (terminal, IDE, or Jupyter Notebook).


๐Ÿ“˜ 1. List All Functions in a Module

You can list all functions within a module using dir():

import autofeatureselect.filters as filters
import autofeatureselect.model_wrappers as models

# List functions in the filters module
print(dir(filters))

# List functions in the model_wrappers module
print(dir(models))

๐Ÿ“‘ 2. Get Help on a Specific Function

Use the help() function to view the docstring of a specific function, including description, parameters, and return values:

from autofeatureselect.filters import mutual_info_filter

help(mutual_info_filter)

๐Ÿ” How It's Different from Other Tools

Feature AutoFeatureSelect Featuretools tsfresh feature-engine scikit-learn
Focus Feature Selection Feature Generation Feature Extraction Manual Engineering General ML
Auto-generate new features โŒ โœ… โœ… โš ๏ธ โš ๏ธ
Remove irrelevant features โœ… โŒ โš ๏ธ Partial โœ… โœ…
Targeted data Tabular Relational Time-series Tabular All
Easy to use โœ… โŒ โŒ โš ๏ธ โœ…
Beginner-friendly โœ… โŒ โŒ โš ๏ธ โš ๏ธ

๐Ÿงช Testing the Package

# Run from the root of the project directory
pytest test/

Ensure pytest is installed:

pip install pytest

๐Ÿ“ Project Structure

autofeatureselect/
โ”‚
โ”œโ”€โ”€ filters.py # Statistical methods
โ”‚ โ”œโ”€โ”€ low_variance_filter()
โ”‚ โ”œโ”€โ”€ correlation_filter()
โ”‚ โ””โ”€โ”€ mutual_info_filter()
โ”‚
โ”œโ”€โ”€ model_wrappers.py # Model-based methods
โ”‚ โ”œโ”€โ”€ tree_importance_filter()
โ”‚ โ”œโ”€โ”€ rfe_filter()
โ”‚ โ””โ”€โ”€ shap_filter()
โ”‚
โ””โ”€โ”€ init.py # Exposes selected functions

๐Ÿ“˜ Documentation

Every function is self-contained and comes with:

  • Docstrings
  • Clear parameters
  • Defaults set to typical values
  • Returns filtered DataFrame (with target column)

You can use Pythonโ€™s built-in help:

from autofeatureselect.filters import mutual_info_filter
help(mutual_info_filter)

Or read the source โ€” itโ€™s clean and readable!


๐Ÿค” What It Does Not Do

  • โŒ It does not create new features (use Featuretools, tsfresh, or scikit-learn for that)
  • โŒ It does not automate the entire pipeline (no one-size-fits-all โ€” feature selection must be task-specific!)
  • โŒ It does not hide logic in โ€œblack boxesโ€ โ€” everything is transparent and user-controllable

๐Ÿ™Œ Contributing

Want to add your own feature selection method?
PRs and discussions welcome! Just follow the modular style, and document everything clearly.


๐Ÿ‘ค Author

Shreenidhi TH
Developer passionate about building tools for applied ML and automation.


License

This project is licensed under the MIT License.


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

smartfeatureselectml-0.1.6.tar.gz (12.2 kB view details)

Uploaded Source

Built Distribution

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

smartfeatureselectml-0.1.6-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file smartfeatureselectml-0.1.6.tar.gz.

File metadata

  • Download URL: smartfeatureselectml-0.1.6.tar.gz
  • Upload date:
  • Size: 12.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for smartfeatureselectml-0.1.6.tar.gz
Algorithm Hash digest
SHA256 f5be85564fd433a0daaba4c31886d529bb5da6d7bf010524bae80ce86b66cee4
MD5 47d6d6b2b1cb17e1d0871686f3675d24
BLAKE2b-256 74e095483f160db64165760c8f3155b8341d81b28e610eff426ed5a97a8327fd

See more details on using hashes here.

File details

Details for the file smartfeatureselectml-0.1.6-py3-none-any.whl.

File metadata

File hashes

Hashes for smartfeatureselectml-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 4e151206867d271afdb634884251fb6fba90ca1c70f226319cd4e494e5c3d793
MD5 cf1bbdf87de89e560a0b1cb8a8281c90
BLAKE2b-256 a216cc59f1262de03aedfe97c98462f3096d52464ade65e69a3eb7e54e916be2

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