skrebate

raw JSON →
0.62 verified Fri May 01 auth: no python maintenance

A scikit-learn-compatible implementation of Relief-based feature selection algorithms for classification and regression. Current version 0.62; development is infrequent (last release 2020).

pip install skrebate
error ImportError: cannot import name 'ReliefF' from 'skrebate'
cause Attempted import from the wrong package or wrong spelling. Possibly confused with 'sklearn' or old version.
fix
Ensure you installed skrebate (pip install skrebate) and import from 'skrebate' (not 'sklearn' or 'scikit-rebate').
error ModuleNotFoundError: No module named 'skrebate'
cause Package not installed or installed in a different environment.
fix
Run 'pip install skrebate'. If using Anaconda, try 'conda install -c conda-forge skrebate'.
error ValueError: n_neighbors should be >= 1, got 0
cause Instantiating ReliefF with n_neighbors=0 or negative.
fix
Set n_neighbors to a positive integer (e.g., 10).
error TypeError: fit() got an unexpected keyword argument 'verbose'
cause Using verbose parameter in newer versions where it was removed.
fix
Remove the verbose argument from fit().
gotcha The 'n_features_to_select' parameter is required and must be specified. If omitted, a warning is issued and no features are selected (transform returns empty array).
fix Always pass n_features_to_select explicitly, even if you want all features (use n_features_to_select=X.shape[1]).
gotcha ReliefF and SURF algorithms expect continuous features. They do not handle categorical features natively; encoding (e.g., one-hot) is required.
fix Apply one-hot encoding or label encoding before fitting. Note that one-hot may increase dimensionality and affect neighbor distances.
deprecated The 'verbose' parameter in fit() is deprecated and may be removed in future versions.
fix Remove verbose flag or set verbose=False.
gotcha skrebate uses 'discrete_threshold' parameter for binarizing continuous features into discrete states for some algorithms. Incorrect setting can lead to poor feature rankings.
fix Set discrete_threshold to the number of discrete values for categorical targets or leave as default (10).

Basic ReliefF feature selection on the Iris dataset

from skrebate import ReliefF
from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split

X, y = load_iris(return_X_y=True)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)

# Feature selection with ReliefF
fs = ReliefF(n_neighbors=10, n_features_to_select=2)
fs.fit(X_train, y_train)
X_train_selected = fs.transform(X_train)
X_test_selected = fs.transform(X_test)
print(X_train_selected.shape)