Multi-objective feature selection with a scikit-learn API: MOFS-RFGA, NSGA-II, Pareto-front visualization and PlatEMO-compatible metrics
Project description
moofs
Multi-Objective Optimization for Feature Selection
A Python library for multi-objective feature selection with a unified, scikit-learn compatible API. moofs searches for the best trade-offs between classification error and number of selected features, returns the full Pareto front, and lets you pick the subset that fits your needs.
Installation
pip install moofs
Quick start
from moofs import MOFSSelector
selector = MOFSSelector(algorithm="mofs-rfga", max_evals=5000, random_state=0)
X_reduced = selector.fit_transform(X, y)
selector.pareto_front_ # (n_solutions, 2): [error %, subset size]
selector.support_ # boolean mask of the chosen subset
selector.get_feature_names_out()
It drops into any scikit-learn pipeline:
from sklearn.pipeline import Pipeline
from sklearn.neighbors import KNeighborsClassifier
pipe = Pipeline([
("fs", MOFSSelector(max_evals=5000, random_state=0)),
("clf", KNeighborsClassifier(n_neighbors=3)),
]).fit(X_train, y_train)
Available algorithms
| Algorithm | Key | Authors | Reference |
|---|---|---|---|
| MOFS-RFGA | mofs-rfga |
Xue, Zhu & Neri (2023) | paper |
| NSGA-II | nsga2 |
Deb, Pratap, Agarwal & Meyarivan (2002) | paper |
More algorithms from the MOFS literature (SparseEA, NSGA-II/SDR, SPEA2, MOEA/D, NSPSOFS, CMDPSOFS) are planned for upcoming releases — see the CHANGELOG.
Visualizing Pareto fronts
from moofs import plot_selector, plot_fronts
plot_selector(selector) # front + highlighted chosen subset
plot_fronts({"MOFS-RFGA": r1, "NSGA-II": r2}, reference=True)
Metrics
Quality indicators follow the PlatEMO definitions used in the MOFS literature, so values are directly comparable with published tables: igd, hv (normalized, reference point (1,1)), coverage (weak dominance), nfs, spacing.
from moofs import compare
table = compare({"MOFS-RFGA": r1, "NSGA-II": r2})
# algorithm IGD HV NFS best_error_% min_subset_size
Research-style API
For experiments and full control over the search:
from moofs import FeatureSelectionProblem, MOFSRFGA, NSGA2
problem = FeatureSelectionProblem(X, y) # KNN k=3, 3-fold CV, cached
result = MOFSRFGA(problem, pop_size=100, max_evals=300_000, seed=0).run()
result.F # objective matrix of the Pareto front
result.front # solutions with binary masks (.x)
The evaluation protocol follows the reference paper: k-NN (k=3) classifier, 3-fold cross-validation, objectives = (classification error %, subset size). Evaluations are memoized; cache hits still count toward max_evals so budgets stay comparable.
Faithfulness notes
Implementations are traceable to their source papers, and ambiguities are documented rather than silently resolved. Notably, the MOFS-RFGA paper's Fig. 1 and its Algorithm 3 disagree on the crossover semantics; moofs defaults to the Fig. 1 reading (consistent with the mutation operator) and exposes interpretation="pseudocode" for the literal alternative. See the documentation for details.
License
MIT — see LICENSE.
Citing
If you use moofs in academic work, please cite the underlying algorithm papers (see the table above). A citable software DOI is planned.
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
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 moofs-0.1.0.tar.gz.
File metadata
- Download URL: moofs-0.1.0.tar.gz
- Upload date:
- Size: 20.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1208eff34b73545c856cd276b1cfd5ac16ddf177582681180377e676867720e4
|
|
| MD5 |
ade052b18fd36853406ded0b344be7e6
|
|
| BLAKE2b-256 |
afe29fcffef4d1a24f96c294ec94d855ae91ff61ac242f714232cbced19317d6
|
Provenance
The following attestation bundles were made for moofs-0.1.0.tar.gz:
Publisher:
release.yml on Quick-AI-ML/moofs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
moofs-0.1.0.tar.gz -
Subject digest:
1208eff34b73545c856cd276b1cfd5ac16ddf177582681180377e676867720e4 - Sigstore transparency entry: 2314405464
- Sigstore integration time:
-
Permalink:
Quick-AI-ML/moofs@856ca9ddd47ad385b661ab1815b273422cef235c -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/Quick-AI-ML
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@856ca9ddd47ad385b661ab1815b273422cef235c -
Trigger Event:
push
-
Statement type:
File details
Details for the file moofs-0.1.0-py3-none-any.whl.
File metadata
- Download URL: moofs-0.1.0-py3-none-any.whl
- Upload date:
- Size: 22.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5a736639853b6c5f88d1c5db399235acf735d00d9af1509a8657bef70ae4c7c5
|
|
| MD5 |
727ffcdabe7062fcdf19256f38f14b87
|
|
| BLAKE2b-256 |
4fa0f33120faff88120acd4b657fa79f52c745afe5e4d72f396602929dbd248b
|
Provenance
The following attestation bundles were made for moofs-0.1.0-py3-none-any.whl:
Publisher:
release.yml on Quick-AI-ML/moofs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
moofs-0.1.0-py3-none-any.whl -
Subject digest:
5a736639853b6c5f88d1c5db399235acf735d00d9af1509a8657bef70ae4c7c5 - Sigstore transparency entry: 2314405560
- Sigstore integration time:
-
Permalink:
Quick-AI-ML/moofs@856ca9ddd47ad385b661ab1815b273422cef235c -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/Quick-AI-ML
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@856ca9ddd47ad385b661ab1815b273422cef235c -
Trigger Event:
push
-
Statement type: