An end-to-end feature selection distribution with linear runtime(number of features) complexity.
Project description
AutoNFS
AutoNFS is a deep learning model that can be used to select the most important features from a given dataset. The model is based on the Gumbel-Sigmoid distribution.
Installation
To install the package, you can use pip:
pip install autonfs
Usage examples
Basic usage
from autonfs import AutoNFS
from sklearn.datasets import load_breast_cancer
breast = load_breast_cancer()
X = breast.data
y = breast.target
gfs = AutoNFS()
X = gfs.fit_transform(X, y)
print(gfs.support_)
print(gfs.scores_)
Performance verification
from autonfs import AutoNFS
from sklearn.datasets import load_breast_cancer
from sklearn.model_selection import train_test_split
from sklearn.ensemble import RandomForestClassifier
from sklearn.metrics import balanced_accuracy_score
DEVICE = "cpu"
breast = load_breast_cancer()
X = breast.data
y = breast.target
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
clf = RandomForestClassifier(random_state=42)
clf.train(X_train, y_train)
orig_score = balanced_accuracy_score(y_test, clf.predict(X_test))
print(f"Original score: {orig_score:.3f}. Original features: {X.shape[1]}")
# Original score: 0.958. Original features: 30
gfs = AutoNFS(verbose=True, device=DEVICE)
gfs.fit(X_train, y_train)
X_transformed = gfs.transform(X_train)
X_test_transformed = gfs.transform(X_test)
clf.fit(X_transformed, y_train)
y_pred = clf.predict(X_test_transformed)
score = balanced_accuracy_score(y_test, y_pred)
logger.info(f"Score after feature selection: {score}. Selected features: {sum(gfs.support_)}")
# Score after feature selection: 0.958. Selected features: 3
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
autonfs-0.3.2.tar.gz
(4.7 kB
view details)
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 autonfs-0.3.2.tar.gz.
File metadata
- Download URL: autonfs-0.3.2.tar.gz
- Upload date:
- Size: 4.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.9.18 Linux/5.10.0-30-amd64
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b09dfe519a2fcd338f7cdcc624f85e9a5dd3e5226ab52f05e3990b8817efdb2c
|
|
| MD5 |
61827c964692cf72ac48f4551a4c67d3
|
|
| BLAKE2b-256 |
0a9849bffacbdd11a71382aa8d0c44c39eef0137666d93d8cb736966cf413620
|
File details
Details for the file autonfs-0.3.2-py3-none-any.whl.
File metadata
- Download URL: autonfs-0.3.2-py3-none-any.whl
- Upload date:
- Size: 5.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.9.18 Linux/5.10.0-30-amd64
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
92a1ae4271a1f9c3b158751ca2a9f2393f5c3f0d5176228743a0adc92849ab81
|
|
| MD5 |
424abbd696f913a4a6ed16b4e78400fc
|
|
| BLAKE2b-256 |
9fa9af6f2c99682de1bf8e2a1b49f67c962c45aba3b6c5ea07025c09739fd325
|