API reference
Selector
Bases: SelectorMixin, BaseEstimator
Multi-objective feature selection with a scikit-learn interface.
Runs a multi-objective algorithm minimizing (classification error %,
number of selected features), then picks one solution from the Pareto
front according to strategy.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
algorithm
|
(mofs - rfga, nsga2)
|
Search algorithm. MOFS-RFGA (Xue, Zhu & Neri, 2023) is the ReliefF-guided hybrid; NSGA-II is the classic baseline. |
"mofs-rfga"
|
pop_size
|
int
|
Population size N. |
60
|
max_evals
|
int
|
Budget in objective-function evaluations (maxFEs). |
5000
|
strategy
|
(knee, min_error, min_features)
|
How to pick the final subset from the Pareto front: "knee" = best normalized trade-off, "min_error" = most accurate, "min_features" = smallest subset. |
"knee"
|
sc
|
array - like
|
Precomputed feature scores for MOFS-RFGA (defaults to built-in ReliefF). Ignored by NSGA-II. |
None
|
random_state
|
int
|
Seed for reproducibility. |
None
|
verbose
|
bool
|
|
False
|
Attributes:
| Name | Type | Description |
|---|---|---|
pareto_front_ |
ndarray of shape (n_solutions, 2)
|
Objective values [error %, subset size] of the final Pareto front. |
pareto_masks_ |
ndarray of shape (n_solutions, n_features)
|
Binary masks of the Pareto-front solutions. |
support_ |
ndarray of shape (n_features,)
|
Boolean mask of the selected subset (per |
result_ |
Result
|
Full algorithm result. |
n_evals_ |
int
|
Evaluations actually consumed. |
Source code in src/moofs/selection.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 | |
fit(X, y)
Run the multi-objective search on (X, y).
Source code in src/moofs/selection.py
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | |
Algorithms
Bases: Algorithm
MOFS-RFGA in the unified API.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sc
|
array-like of float
|
Feature-score vector (higher = better). If None, ReliefF scores are
computed automatically from |
None
|
D_init
|
int
|
Upper bound on the number of features selected at initialisation;
defaults to |
None
|
Source code in src/moofs/algorithms/mofs_rfga.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 | |
Bases: Algorithm
NSGA-II for binary multi-objective feature selection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pc
|
float
|
Crossover probability. |
0.9
|
pm
|
float
|
Per-gene mutation probability; defaults to 1/D. |
None
|
crossover
|
(single_point, uniform)
|
|
"single_point"
|
Source code in src/moofs/algorithms/nsga2.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | |
Problem
Bases: Problem
Wrapper-based multi-objective feature selection problem.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
X
|
DataFrame
|
Feature matrix. |
required |
y
|
Series
|
Target labels. |
required |
estimator
|
sklearn classifier
|
Defaults to |
None
|
n_splits
|
int
|
Number of CV folds. |
3
|
random_state
|
int
|
Seed of the K-Fold shuffling (fixed so that f1 is deterministic and cacheable). |
64
|
cache
|
bool
|
Memoize evaluations. Cache hits still increment |
True
|
Source code in src/moofs/core/problem.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | |
Metrics
Quality indicators for multi-objective solution sets, PlatEMO-compatible.
The IGD, HV and coverage definitions follow the PlatEMO implementations used in the MOFS literature (Tian et al., PlatEMO, IEEE CIM 2017), so values are directly comparable with published tables:
igd: mean of the minimum distances from each reference point (IGD.m).hv: exact 2-D hypervolume after PlatEMO normalization (HV.m): objectives scaled by 1.1 * (max(PF) - fmin), reference point (1, 1).coverage: weak-dominance set coverage (Coverage.m).
All functions accept 2-D objective arrays, lists of Solution, or a
Result.
compare(results, reference_front=None)
Metric table for a set of results.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
results
|
dict
|
Mapping |
required |
reference_front
|
array - like
|
Reference front; defaults to the non-dominated union of all results. |
None
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
One row per algorithm: IGD, HV, NFS, best error, smallest subset. |
Source code in src/moofs/metrics.py
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 | |
coverage(A, B)
Set coverage SC(A, B),
Fraction of solutions in B that are weakly dominated by (i.e. no better in any objective than) at least one solution in A.
Source code in src/moofs/metrics.py
109 110 111 112 113 114 115 116 117 118 119 120 121 122 | |
gd(reference_front, front)
Generational Distance (lower is better).
Source code in src/moofs/metrics.py
44 45 46 47 48 49 50 51 | |
hv(front, reference_front)
Hypervolume, PlatEMO definition (higher is better).
Objectives are normalized by fmin = min(min(front), 0) and
fmax = max(reference_front) with a 1.1 scaling factor; points beyond
the (1, 1) reference point are discarded; the exact 2-D hypervolume of
the remaining non-dominated points is returned.
Source code in src/moofs/metrics.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | |
igd(reference_front, front)
Inverted Generational Distance, PlatEMO definition (lower is better).
Source code in src/moofs/metrics.py
34 35 36 37 38 39 40 41 | |
merge_reference_front(*fronts)
Reference ("true") Pareto front: non-dominated union of several fronts.
This follows the protocol of the MOFS literature: the fronts of all algorithms are merged and non-dominated sorted; the first front is treated as the reference.
Source code in src/moofs/metrics.py
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 | |
nfs(front)
Number of Feature Subsets: distinct solutions in the front.
Source code in src/moofs/metrics.py
125 126 127 128 | |
spacing(front)
Schott's spacing metric (lower = more uniform distribution).
Source code in src/moofs/metrics.py
131 132 133 134 135 136 137 138 139 | |
Plotting
Pareto-front visualization helpers (matplotlib).
Every function accepts a Result, a list of Solution or a 2-D
objective array, returns the matplotlib Axes for further styling, and
never calls plt.show() — the caller stays in control.
plot_fronts(results, ax=None, reference=False)
Overlay several Pareto fronts for comparison.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
results
|
dict
|
Mapping |
required |
reference
|
bool
|
Also draw the merged reference front as a dashed line. |
False
|
Source code in src/moofs/plotting.py
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | |
plot_pareto_front(result, label=None, ax=None, color=None, marker='o', annotate=False)
Scatter plot of one Pareto front (error % vs. subset size).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result
|
Result, list of Solution, or ndarray
|
|
required |
label
|
str
|
Legend label (defaults to the algorithm name if available). |
None
|
ax
|
Axes
|
|
None
|
annotate
|
bool
|
Write the subset size next to each point. |
False
|
Source code in src/moofs/plotting.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | |
plot_selector(selector, ax=None)
Plot a fitted MOFSSelector front and highlight the chosen subset.
Source code in src/moofs/plotting.py
84 85 86 87 88 89 90 91 92 93 94 95 | |