Skip to main content

Package information: Python 3.9 Python 3.10 Python 3.11 Python 3.12 License PyPI version

scikit-rebate

This package includes a scikit-learn-compatible Python implementation of ReBATE, a suite of Relief-based feature selection algorithms (RBAs) for machine learning. These Relief-based algorithms (RBAs) are designed for feature weighting/selection as part of a machine learning pipeline (supervised learning). These algorithms offer a computationally efficient way to perform feature selection that is sensitive to feature interactions as well as simple univariate associations, unlike most currently available filter-based feature selection methods. The main benefit of Relief-based algorithms is that they identify feature interactions without having to exhaustively check every pairwise interaction, thus taking significantly less time than exhaustive pairwise search.

Relief-based algorithms can be applied to almost any structured, labeled tabular dataset for supervised learning. For example, these algorithms have commonly been applied to genetic/genomic analyses given that can detect features involved in epistasis (i.e. feature interactions) and they scale linearly with number of features (however note that they scale quadratically number of training instances).

We refer to the different RBA options as 'core' algorithms which presently include Relief, ReliefF, SURF, SURF*, MultiSURF*, MultiSURF, SWRF*, SWRF, MultiSWRF*, MultiSWRF, MultiSWRFDB*, MultiSWRFDB, and μ-Relief. Core algorithms are generally very reliable at detecting pure 2-way interactions (heritability of 0.4) in datasets with up to 5000-10000 features. Additionally, implementations of RBA 'wrapper' algorithms are currently available, including TuRF, VLS, and a combination of TuRF+VLS. These wrapper algorithms help RBAs scale up their sensitivity to even pure interactions in datasets with > 10000 features to at least 100K features.

Importantly, all RBA algorithms in this package support datasets with the following characteristics:

  • Feature sets that are discrete/categorical, continuous-valued or a mix of both

  • Data with missing values

  • Binary endpoints (i.e., classification)

  • Multi-class endpoints (i.e., classification)

  • Continuous endpoints (i.e., regression)

Of note, certain core algorithms have hyperparameter options that users can specify (beyond default settings), e.g. ReliefF’s parameter for ‘k’ number of nearest neighbors. These packages 'automatically detect these relevant characteristics from loaded data. However, when it comes to treating features appropriately as either categorical vs. quantiative features we recommend users specify feature types (using the categorical_features hyperparameter) rather than relying on categorical_threshold hyperparameter which can be inprecise in assigning feature types.

Full documentation for this package is available at: usage documentation.

This reposistory is still under active development, thus we encourage you to notify us if you discovery any bugs as well as check this respository for package updates.

License

Please see the repository license for the licensing and usage information for scikit-rebate.

We have licensed scikit-rebate to make it as widely usable as possible.

Installation

scikit-rebate is built on top of the following existing Python packages:

  • NumPy

  • SciPy

  • scikit-learn

All of the necessary Python packages can be installed via the Anaconda Python distribution, which we strongly recommend that you use. We also strongly recommend that you use Python 3 over Python 2 if you're given the choice.

NumPy, SciPy, and scikit-learn can be installed in Anaconda via the command:

conda install numpy scipy scikit-learn

Once the prerequisites are installed, you should be able to install scikit-rebate with a pip command:

pip install skrebate

Please file a new issue if you run into installation problems.

Usage

Basic Usage

To use an algorithm from ReBATE as a feature selection method:

# Import necessary packages
import pandas as pd
from skrebate import ReliefF

# Load the example dataset
genetic_data = pd.read_csv(
    './data/GAMETES_Epistasis_2-Way_20atts_0.4H_EDM-1_1.csv')

# Separate the features and labels from the dataset
features, labels = genetic_data.drop('class', axis=1).values, genetic_data['class'].values

# Apply the ReliefF algorithm for feature selection
fs = ReliefF()
fs.fit(features, labels)

# Print out the results
feature_name = genetic_data.drop('class', axis=1).columns
fs.summary(feature_name=feature_name)

>>> Feature name   Feature importances    Feature rank
>>> P2             0.12330000             1
>>> P1             0.11892500             2
>>> N0             -0.00018125            3
>>> N10            -0.00075625            4
>>> N13            -0.00320625            5
>>> N14            -0.00402500            6
>>> N4             -0.00582500            7
>>> N1             -0.00595000            8
>>> N8             -0.00653750            9
>>> N12            -0.00696250            10
>>> N16            -0.00705000            11
>>> N17            -0.00740625            12
>>> N5             -0.00788750            13
>>> N11            -0.00822500            14
>>> N9             -0.00826250            15
>>> N2             -0.00871875            16
>>> N3             -0.00872500            17
>>> N7             -0.00991875            18
>>> N6             -0.01038750            19
>>> N15            -0.01044375            20

Using as End-to-end Pipeline

We have designed the Relief-based algorithms to be integrated directly into scikit-learn machine learning workflows. For example, the ReliefF algorithm can be used as a feature selection step in a scikit-learn pipeline as follows:

# Import necessary packages
import pandas as pd
from sklearn.pipeline import make_pipeline
from skrebate import ReliefF
from sklearn.ensemble import RandomForestClassifier
from sklearn.model_selection import train_test_split
from sklearn.metrics import accuracy_score

# Load the example dataset
genetic_data = pd.read_csv(
    './data/GAMETES_Epistasis_2-Way_20atts_0.4H_EDM-1_1.csv')

# Separate the features and labels from the dataset
features, labels = genetic_data.drop('class', axis=1).values, genetic_data['class'].values

# Split the data to training and testing
X_train, X_test, y_train, y_test = train_test_split(features, labels, test_size=0.3, random_state=42)

# Make pipeline
clf = make_pipeline(
    ReliefF(n_features_to_select=2),
    RandomForestClassifier(n_estimators=100)
)

# Train the model
clf.fit(X_train, y_train)

# Evaluate the model on testing set
y_pred = clf.predict(X_test)
accuracy = accuracy_score(y_test, y_pred)
print(f"Accuracy: {accuracy:.3f}")
>>> Accuracy: 0.781

Contributing to scikit-rebate

We welcome you to check the existing issues for bugs or enhancements to work on. If you have an idea for an extension to scikit-rebate, please file a new issue so we can discuss it.

Please refer to our contribution guidelines prior to working on a new feature or bug fix.

Citing scikit-rebate

Please note that a new manuscript on this updated ReBATE package has been recently submitted for publication. In the meantime, if you use scikit-rebate in a scientific publication, please consider citing the following paper:

Ryan J. Urbanowicz, Randal S. Olson, Peter Schmitt, Melissa Meeker, Jason H. Moore (2018). Benchmarking Relief-Based Feature Selection Methods for Bioinformatics Data Mining. Journal of Biomedical Informatics, 85, 168-188. DOI: 10.1016/j.jbi.2018.07.015

BibTeX entry:

@article{Urbanowicz2018Benchmarking,
  author    = {Urbanowicz, Ryan J. and Olson, Randal S. and Schmitt, Peter and Meeker, Melissa and Moore, Jason H.},
  title     = {Benchmarking Relief-Based Feature Selection Methods for Bioinformatics Data Mining},
  journal   = {Journal of Biomedical Informatics},
  volume    = {85},
  pages     = {168--188},
  year      = {2018},
  doi       = {10.1016/j.jbi.2018.07.015},
  url       = {https://doi.org/10.1016/j.jbi.2018.07.015}
}

Download files

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

Source Distribution

skrebate-0.8.3.tar.gz (45.2 kB view details)

Uploaded Source

Built Distribution

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

skrebate-0.8.3-py3-none-any.whl (55.1 kB view details)

Uploaded Python 3

File details

Details for the file skrebate-0.8.3.tar.gz.

File metadata

  • Download URL: skrebate-0.8.3.tar.gz
  • Upload date:
  • Size: 45.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.10.20

File hashes

Hashes for skrebate-0.8.3.tar.gz
Algorithm Hash digest
SHA256 ce6be1ce89a86da42814509e43fa8592d330462f7f6af241fb1fc2178d292190
MD5 a7cc5bc90688ce33a0e10fbd181dea2b
BLAKE2b-256 744dcd3ed862f79b09c5e9614a8860cadd8aa8ce1cf4f6fdcfc1fc5606605a46

See more details on using hashes here.

File details

Details for the file skrebate-0.8.3-py3-none-any.whl.

File metadata

  • Download URL: skrebate-0.8.3-py3-none-any.whl
  • Upload date:
  • Size: 55.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.10.20

File hashes

Hashes for skrebate-0.8.3-py3-none-any.whl
Algorithm Hash digest
SHA256 50cc579d6d13989d2f01d5f53e36dbd22260eab80d744cb793b4483e15666867
MD5 e34a3a058790b010012bfadc302cddd2
BLAKE2b-256 b5cf9b2753fb93971b1bcce65c7730aca8eafbe50e614ae7c59969ffd25a6934

See more details on using hashes here.

Release history Release notifications | RSS feed

0.62

1 file

0.61

1 file

This release

0.8.3 This release

2 files

0.8.2

2 files

0.8.1

2 files

0.8

2 files

0.7

1 file

0.6

1 file

0.5

1 file

0.4

1 file

0.3.4

1 file

0.3.3

1 file

0.3.2

1 file

0.3.1

1 file

0.3

1 file

0.2

1 file

0.1

1 file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page