This repository is provided for academic and research visibility. No open-source software license is currently granted. If you use or refer to this implementation in academic work, please cite the associated paper. For permission to reuse, modify, or redistribute the code, please contact the authors.
The included article is distributed under the Creative Commons Attribution 4.0 license stated in the paper.
MATLAB implementation of B-MFO, a binary Moth-Flame Optimization algorithm for wrapper-based feature selection. B-MFO converts continuous MFO search positions into binary feature-selection decisions through 12 transfer functions in three families: S-shaped, V-shaped, and U-shaped.
M. H. Nadimi-Shahraki, M. Banaie-Dezfouli, H. Zamani, S. Taghian, and S. Mirjalili, "B-MFO: A Binary Moth-Flame Optimization for Feature Selection from Medical Datasets," Computers, vol. 10, no. 11, article 136, 2021. https://doi.org/10.3390/computers10110136
The paper is open access: read the copy included in this repository or view the published article.
B-MFO represents a candidate feature subset as a binary vector. A value of 1 selects a feature and 0 excludes it. At each iteration, the algorithm:
- evaluates every moth using a wrapper-based classifier;
- ranks moths and retains the best solutions as flames;
- updates continuous moth positions using the MFO logarithmic spiral;
- maps the continuous positions to binary decisions using a selected transfer function; and
- reduces the number of active flames progressively to balance exploration and exploitation.
The computational complexity discussed in the paper is O(NDT), where N is the population size, D is the number of features, and T is the maximum number of iterations.
Set transferFunctionID in Main.m to an integer from 1 to 12:
| IDs | Family | Variants |
|---|---|---|
| 1-4 | S-shaped | S1-S4 |
| 5-8 | V-shaped | V1-V4 |
| 9-12 | U-shaped | U1-U4 |
The supplied demonstration uses S2 (transferFunctionID = 2). The paper evaluates all 12 variants; the best variant depends on the dataset.
| File | Purpose |
|---|---|
Main.m |
Configures and runs the demonstration |
B_MFO.m |
Main B-MFO optimization procedure |
Bstep_B_MFO.m |
Implements the 12 binary transfer functions |
jFitnessFunction.m |
Demonstration wrapper fitness using 5-NN |
ionosphere.mat |
Demonstration dataset (feat and label) |
paper/B-MFO-paper.pdf |
Open-access copy of the associated article |
CITATION.cff |
Machine-readable citation metadata |
- MATLAB R2018a or later
- Statistics and Machine Learning Toolbox (
cvpartition,fitcknn, andpredict)
The code was originally developed in MATLAB R2018a.
- Download or clone this repository.
- Open the repository folder in MATLAB.
- Run:
MainThe script loads the included Ionosphere demonstration dataset, creates a stratified holdout partition, runs B-MFO, prints the best fitness at each iteration, and plots the convergence curve. The main outputs are:
sFeat: reduced dataset containing the selected features;Sf: indices of the selected features;Nf: number of selected features; andcurve: best fitness value at each iteration.
To use your own dataset, supply:
feat % numeric matrix: rows = samples, columns = features
label % response vector: one label per sampleThen replace load ionosphere.mat in Main.m with your data-loading code.
This repository is a compact demonstration release. Its default settings are 10 moths, 100 iterations, one S2 transfer-function run, and a 20% stratified holdout evaluated by 5-NN classification error.
The published experimental protocol used 20 moths, 300 iterations, 30 independent runs, 10-fold cross-validation, seven medical datasets, and evaluation of all 12 transfer-function variants. Therefore, the default demo is intended to illustrate the implementation and may not reproduce the numerical tables in the paper directly.
The algorithm is stochastic. For a repeatable demonstration, uncomment the rng(1,'twister') line in Main.m. For research comparisons, use multiple independent runs and report the mean and standard deviation.
If this code contributes to your research, please cite the associated article:
@article{NadimiShahraki2021BMFO,
author = {Nadimi-Shahraki, Mohammad H. and Banaie-Dezfouli, Mahdis and Zamani, Hoda and Taghian, Shokooh and Mirjalili, Seyedali},
title = {B-MFO: A Binary Moth-Flame Optimization for Feature Selection from Medical Datasets},
journal = {Computers},
volume = {10},
number = {11},
pages = {136},
year = {2021},
doi = {10.3390/computers10110136}
}Mahdis Banaie-Dezfouli
GitHub: MahdisBD
Email: mahdis.dezfouli@gmail.com
Corresponding author of the paper: Mohammad H. Nadimi-Shahraki (nadimi@iaun.ac.ir).
This repository is provided for academic and research visibility. No open-source software license is currently granted. If you use or refer to this implementation in academic work, please cite the associated paper. For permission to reuse, modify, or redistribute the code, please contact the authors.
The included article is distributed under the Creative Commons Attribution 4.0 license stated in the paper.