This library is built to perform feature selection in clustering models
Project description
📊 FeatureClus: Feature Selection for Clustering Models
Welcome to FeatureClus, a Python library designed to simplify feature selection for clustering models. This tool helps you select the most relevant features that enhance clustering performance, ensuring you avoid the "curse of dimensionality" and make your clustering algorithms more efficient and interpretable. 🧠
🔍 How It Works
The feature selection process is driven by evaluating how each feature impacts the clustering results. FeatureClus uses an isolated data shift for each feature to assess its importance. The process follows these steps:
- MinMaxScaler: First, we scale the features using MinMaxScaler to normalize the data.
- PCA (80% variance): Next, we apply Principal Component Analysis (PCA) to reduce dimensionality, retaining 80% of the variance.
- DBSCAN Clustering: After reducing the dimensionality, DBSCAN is used to perform clustering.
- Silhouette Score Calculation: For each feature, we calculate the silhouette score to evaluate the quality of the clusters. The silhouette score represents how similar an object is to its own cluster compared to other clusters.
- Data Shift and Feature Importance: By applying isolated shifts to each feature and recalculating the silhouette score, we measure how the score changes. The absolute difference in the silhouette score after shifting each feature is used to rank the features by importance.
This method ensures that the features are evaluated for their individual contribution to the clustering process, allowing you to focus on the most impactful features.
🚀 Key Features
- 🔍 Feature Ranking: Ranks features based on the absolute change in silhouette score after applying isolated shifts to each feature.
- 📈 Cluster Evaluation Metrics: Calculates the silhouette score to assess the clustering quality and the influence of each feature.
- 💻 Easy-to-Use API: A simple, intuitive API that can be easily integrated into your machine learning pipeline.
📦 Installation
To install the library, run the following command:
pip install featclus
📊 Example
Here is a quick example of how to use FeatureClus with a clustering algorithm (e.g., KMeans):
from featureclus import FeatureSelection
from sklearn.datasets import make_blobs
# Sample DataFrame
data, labels = make_blobs(n_samples=10000, centers=7, n_features=15, random_state=42)
df = pd.DataFrame(data, columns=[f"Feature_{i}" for i in range(15)])
# Initialize the FeatureSelection
model = FeatureSelection(data=df, shifts=[1, 25, 50, 75, 100], n_jobs=-1)
# See how the metrics are important
metrics2 = model2.get_metrics()
🛠️ Methods
get_metrics()
Returns metrics that assess how each feature contributes to clustering.
plot_results(n_features)
Selects the top n_features features based on their importance to clustering results.
☕ Support the Project
If you find this inventory optimization tool helpful and would like to support its continued development, consider buying me a coffee. Your support helps maintain and improve this project!
Other Ways to Support
- ⭐ Star this repository
- 🍴 Fork it and contribute
- 📢 Share it with others who might find it useful
- 🐛 Report issues or suggest new features
Your support, in any form, is greatly appreciated! 🙏
📝 License
This project is licensed under the MIT License. See the LICENSE file for more details.
Happy clustering! 🎉
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file featclus-0.1.3.tar.gz.
File metadata
- Download URL: featclus-0.1.3.tar.gz
- Upload date:
- Size: 7.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f1c434349e8992d4f8b081fb2e529e25b351db81029009fc773be67607f1f830
|
|
| MD5 |
a6443599a6e96ea8e6fe89bc02e2718a
|
|
| BLAKE2b-256 |
1375bdee1815f2ee8e0a9d8e8284304daa61c4082bcb7a4fbb83310f1abff7cd
|
Provenance
The following attestation bundles were made for featclus-0.1.3.tar.gz:
Publisher:
cd.yaml on sebassaras02/featclus
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
featclus-0.1.3.tar.gz -
Subject digest:
f1c434349e8992d4f8b081fb2e529e25b351db81029009fc773be67607f1f830 - Sigstore transparency entry: 711935449
- Sigstore integration time:
-
Permalink:
sebassaras02/featclus@f97e055e8931fe4ac67545a25cc73d76ebb7c89f -
Branch / Tag:
refs/heads/master - Owner: https://github.com/sebassaras02
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
cd.yaml@f97e055e8931fe4ac67545a25cc73d76ebb7c89f -
Trigger Event:
workflow_run
-
Statement type:
File details
Details for the file featclus-0.1.3-py3-none-any.whl.
File metadata
- Download URL: featclus-0.1.3-py3-none-any.whl
- Upload date:
- Size: 6.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
590968ef84e70c69b2e73b2e2b41095a297b290a8c7276db941657aecf540d13
|
|
| MD5 |
796e1897a5e89e540823dce2b904a44b
|
|
| BLAKE2b-256 |
e8c1a7315ccd64d9db9805e034931105e93b36c08e182c6f24b6ba1f20ed068d
|
Provenance
The following attestation bundles were made for featclus-0.1.3-py3-none-any.whl:
Publisher:
cd.yaml on sebassaras02/featclus
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
featclus-0.1.3-py3-none-any.whl -
Subject digest:
590968ef84e70c69b2e73b2e2b41095a297b290a8c7276db941657aecf540d13 - Sigstore transparency entry: 711935460
- Sigstore integration time:
-
Permalink:
sebassaras02/featclus@f97e055e8931fe4ac67545a25cc73d76ebb7c89f -
Branch / Tag:
refs/heads/master - Owner: https://github.com/sebassaras02
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
cd.yaml@f97e055e8931fe4ac67545a25cc73d76ebb7c89f -
Trigger Event:
workflow_run
-
Statement type: