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.
Release files for moofs 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| moofs-0.1.0.tar.gz | 20.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| moofs-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 42.9 kB
Release files / moofs-0.1.0.tar.gz
| Download URL | moofs-0.1.0.tar.gz |
|---|---|
| Size | 20.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1208eff34b73545c856cd276b1cfd5ac16ddf177582681180377e676867720e4
|
|
BLAKE2b-256 checksum How to use checksums |
afe29fcffef4d1a24f96c294ec94d855ae91ff61ac242f714232cbced19317d6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 1, 2026.
Transparency logRelease files / moofs-0.1.0-py3-none-any.whl
| Download URL | moofs-0.1.0-py3-none-any.whl |
|---|---|
| Size | 22.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5a736639853b6c5f88d1c5db399235acf735d00d9af1509a8657bef70ae4c7c5
|
|
BLAKE2b-256 checksum How to use checksums |
4fa0f33120faff88120acd4b657fa79f52c745afe5e4d72f396602929dbd248b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 1, 2026.
Transparency log