Rough set Quick reduct/ feature selection in Python
ML System Design practice on Codemia
Design recommenders, ranking systems and training pipelines the way ML interviews actually ask for them, with worked solutions.
Introduction
Quick Reduct is a greedy feature-selection method from rough set theory. Its goal is to find a small subset of condition attributes that preserves the decision-making power of the full attribute set, which makes it useful when you want interpretable, rule-oriented feature reduction rather than a purely model-driven importance score.
Rough set concepts that matter in practice
Rough set methods assume that objects are described by condition attributes and one decision attribute. Two rows are indiscernible under a subset of features if they have the same values for those features. If every row inside one of those groups shares the same decision value, that group belongs to the positive region for the subset.
The dependency degree measures how much of the dataset can be classified with certainty using the chosen features:
- universe
U: all rows - positive region
POS_P(D): rows certainly classified by subsetP - dependency degree:
|POS_P(D)| / |U|
A reduct is a subset of features that reaches the same dependency degree as the full set. Quick Reduct tries to find such a subset without exhaustively testing every combination.
Why Quick Reduct is greedy
An exhaustive reduct search is combinatorial and becomes expensive quickly. Quick Reduct avoids that by repeatedly adding the single feature that improves dependency the most at the current step.
The algorithm is:
- start with an empty subset
- evaluate each unused feature when added to the current subset
- keep the feature with the largest dependency gain
- stop when the subset matches the dependency of the full condition set
This is efficient and often good enough, but it does not guarantee the smallest possible reduct in every dataset.
A dependency-degree implementation in Python
The easiest way to prototype this in Python is with pandas. Group by the candidate attributes, then count how many groups are decision-pure.
This implementation is intentionally direct. It is not optimized for very large datasets, but it makes the rough set logic easy to verify.
Quick Reduct implementation
This function returns both the selected reduct and the score it achieved, which makes debugging easier when the greedy search stops short of the full-set dependency.
Example dataset and result
On a small table like this, the result is easy to inspect manually. That matters because rough set feature selection is about preserving discernibility, not maximizing the accuracy of a separate classifier.
Discretization is usually required
Quick Reduct works best on categorical or discretized data. If you feed in continuous measurements directly, many rows become unique under grouping, which can distort the positive region and make the result less meaningful.
A common fix is to bin numeric features before running the algorithm.
Discretization is not a detail. It changes the equivalence classes that rough set reasoning depends on, so it should be chosen deliberately and documented.
How to interpret the output
If Quick Reduct returns a small subset with the same dependency as the full set, those omitted features are redundant under this rough set view of the data. That does not mean they are useless in every machine learning model. It means they do not add new discernibility for the target relative to the chosen discretization and data sample.
That distinction is important. Rough set reduction is a structural criterion, not a drop-in replacement for model validation.
Common Pitfalls
A common mistake is running rough set selection on continuous features without discretization. That usually weakens the meaning of the equivalence classes.
Another mistake is assuming Quick Reduct always finds the smallest possible reduct. It is greedy, so it finds a good reduct quickly, not necessarily the optimal one.
A third mistake is interpreting dependency degree as model accuracy. It measures certainty within rough set partitions, which is related to classification structure but not the same thing as test performance.
Summary
- Quick Reduct is a greedy rough set algorithm for feature reduction.
- It adds features until the subset reaches the dependency degree of the full condition set.
- '
pandas.groupby()is enough to build a clear prototype in Python.' - Discretization is usually necessary before applying the method to numeric data.
- Treat the result as an interpretable structural reduction, not as a direct replacement for model evaluation.
Related reading
- Run localhost server in Google Colab notebook
- Running Tensorflow in Jupyter Notebook
- RuntimeError main thread is not in main loop with Matplotlib and Flask
- RuntimeError module compiled against API version 0xc but this version of numpy is 0xb
- Rounding a list of values to the nearest value from another list in python
- ruby how to generate a tree structure form array?
- Round to 5 or other number in Python
- Rounding DateTime objects

DSA Fundamentals
Master algorithmic patterns and data structures through hands-on LeetCode-style problems - from arrays and hashing to dynamic programming and advanced graphs.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
ML System Design practice on Codemia
Design recommenders, ranking systems and training pipelines the way ML interviews actually ask for them, with worked solutions.