A Python-based feature selection tool using the Sailfish Optimizer (SFO) and other evolutionary algorithms, with SVM as the classifier. This project compares the performance of multiple metaheuristic algorithms on different datasets for feature selection.
- Feature selection using:
- Sailfish Optimizer (SFO)
- Genetic Algorithm (GA)
- Whale Optimization Algorithm (WOA)
- Elephant Herding Optimization (EHO)
- Grey Wolf Optimizer (GWO)
- Moth-Flame Optimizer (MFO)
- Objective function combining feature reduction and accuracy
- Evaluation via SVM with linear kernel
- Dataset handling and cross-validation
- Results saving for comparison
- Python 3.7+
numpyscikit-learnmealpy
Install dependencies using:
pip install numpy scikit-learn mealpy-
Data Preparation:
Datasets are split into train and test sets. Data is normalized using standard preprocessing. -
Binary Feature Selection:
Real-valued outputs from the optimizers are converted into binary feature masks. -
Objective Function:
cost = (alpha * (1 - accuracy)) + (beta * (num_features_selected / total_features))
Where
alphaandbetabalance accuracy vs. feature reduction. -
Optimization Algorithms:
Each algorithm runs multiple times to solve the same optimization problem for comparison. -
Classification:
A Support Vector Machine (SVM) is trained on the selected features and accuracy is measured.
SFOModel = SFO.OriginalSFO(epoch=30, pop_size=50, pp=0.1, AP=4, epsilon=0.01)
g_best = SFOModel.solve(problem_dict)
save_results(g_best, "SFO", num_features, dataset["name"])Repeat similar steps for GA, EHO, WOA, GWO, and MFO.
The accuracy and number of features selected are recorded for each algorithm and dataset. You can modify the save_results function to log results as CSV or visualize them.