This is an implementation of rough sets feature reduction algorithm, based on MATLAB code from Dingyu Xue, YangQuan Chen. Solving applied mathematical problems with MATLAB. Integration with scikit-learn package is also provided.
The package can be easily installed using Python's pip
utility:
pip install git+https://github.com/paudan/scikit-roughsets.git
The usage is very straightforward, identical to scikit
feature selection module:
from scikit_roughsets.rs_reduction import RoughSetsSelector
import numpy as np
y = np.array([[1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1]]).T
X = np.array([[1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 1],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0],
[0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1],
[1, 0, 0, 1, 1, 1, 1, 1, 0, 1, 1, 0],
[0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1],
[1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1],
[1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 1],
[1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 1],
[1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 1],
[1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 1],
[1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 1]])
selector = RoughSetsSelector()
X_selected = selector.fit(X, y).transform(X)
Several restrictions apply to its current use:
- X must be an integer matrix, and y must must be an integer array
- It does not work with NaN values, thus, initial preprocessing must be performed by the user
Tests can be run using pytest
tool:
pytest tests/tests.py