Skip to main content

Feature Selection for Clustering

Project description

Feature Selection for Clustering: fselect

CI PyPI version Python versions License Downloads Monthly downloads

A fast and scalable implementation of A-RANK algorithm as proposed by Dash, M. and Liu, H. in their paper "Feature Selection for Clustering" for selecting features from a dataset using an entropy measure using fast python libraries: numpy, pandas and scikit-learn.

Getting Started

Install the package:

pip install fselect

Import the main function:

from fselect import rank_features  

Prepare a dataframe with normalized continuous features:

import pandas as pd

df = pd.DataFrame({
    'feature1': [...],
    'feature2': [...],    
    [...]
})

Rank the features:

ranked_df = rank_features(df)  

The returned dataframe `ranked_df` contains columns: "rank", "feature", "entropy" sorted by entropy.

Usage

The main parameters:

  • dataframe: pd.DataFrame - Input dataframe with continuous normalized features
  • remove_correlated_columns: bool (optional) - Whether to remove highly correlated columns before ranking
  • correlation_threshold: float (optional) - Correlation threshold to determine correlated columns (default 0.999)

Remove correlated columns first

ranked_df = rank_features(df, remove_correlated_columns=True)  

Custom correlation threshold

ranked_df = rank_features(df, remove_correlated_columns=True, correlation_threshold=0.95) 

Algorithm

The entropy calculation is based on the equations defined in the ARANK paper. It calculates a similarity matrix of the dataframe and computes entropy from the same.

Development

The project targets Python 3.10–3.14 and uses uv.

uv venv            # create the virtual environment
uv sync            # install runtime + dev (pytest) dependencies
uv run pytest      # run the test suite
uv build           # build the sdist + wheel (hatchling backend)

Run the suite against a specific interpreter (uv fetches it if needed):

uv run --python 3.10 pytest

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

fselect-1.1.0.tar.gz (36.6 kB view details)

Uploaded Source

Built Distribution

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

fselect-1.1.0-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

Details for the file fselect-1.1.0.tar.gz.

File metadata

  • Download URL: fselect-1.1.0.tar.gz
  • Upload date:
  • Size: 36.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for fselect-1.1.0.tar.gz
Algorithm Hash digest
SHA256 83fe368ecffff45570f8897a7bee9769a04facb072416c2f91b65e34b3a1c49f
MD5 290cd1c8c9f22c729216a032796a1eed
BLAKE2b-256 bd66e5fccfccaddc26f1fe0af97d6d4ad9befae880f4bdb52edb21c88e568c9d

See more details on using hashes here.

File details

Details for the file fselect-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: fselect-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for fselect-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3d711a7d9e97722adb2288260ea991f36768bf445630331abc2dcf232efdddab
MD5 61a779644ebdf7e0b36de99b684ec833
BLAKE2b-256 a50bec6bfaff8e2c7e379cde7e28b1e853ffcfd93e49ca1844fb7cef94dc0804

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