Why Swarm Intelligence and Genetic Algorithms have a long way to go in Machine learning? | My Neural Path #2


Hey there, curious minds!
This blog is a continuation of the previous one, where I initially optimized Random Forest and SVM using Nature-Inspired Optimization Techniques.
Welcome to the series, “My Neural Path”, where I share my AI experimentation journey- Experiments, Hypothesis, what worked, what didn’t, and what’s coming next.
Since the last blog, I explored several optimization techniques, and Particle Swarm Optimization (PSO) and Mother Tree Optimization (MTO) stood out as the most promising. This time, I evaluated the Baseline model, Optuna-based model, Bald Eagle Optimization (BEO), Particle Swarm Optimization (PSO), and Mother Tree Optimization (MTO) for Random Forest and SVM across six datasets.
MNIST Dataset (Handwritten Digits based image dataset)
Chinese Dataset (Handwritten Kanji based image dataset)
Oxford’s Flower 102 Dataset (Image based 102 different class of flowers)
Caltech 101 Dataset (Image based 101 different object classes)
Adult’s Census Income (Tabular Dataset)
Bank Marketing Dataset (Tabular Dataset)
Churn Modelling Dataset (Tabular Dataset)
Among these datasets, Oxford’s Flower 102 and Caltech 101 performed poorly, even after applying PCA to reduce their high dimensionality. This could be due to Random Forest and SVM not being well-suited for image-based datasets. As a result, I dropped them and focused my evaluations on the remaining datasets.
What is Swarm Intelligence?
Swarm Intelligence (SI) is an inspiration from the collective behaviour of natural systems that work in a group or swarm. It focuses on self-organized systems where agents interact with each other and their environment for a common objective. For example -
a) Ant Swarm: Below is a picture where ants are working in a group/swarm to fulfil a common objective which is to reach point B from point A by using themselves as a bridge.
b) Bee Swarm: You will be familiar with the below picture for sure, it’s a bee hive. Bee’s too work in swarms to fulfil a common objective that is to collect and bring pulp from flowers to produce Honey (Worker Bee’s) or protect the Queen Bee’s Nest/Colony (Guard Bee’s).
When the Swarm Intelligence Inspired optimization techniques are made then it is said that these optimization techniques don’t get stuck in local minima and adapt well to a dynamic environment. Some popular SI-based techniques are Particle Swarm Optimization (PSO), Mother Tree Optimization (MTO), Ant Colony Optimization (ACO) etc.
Hypothesis: Swarm Intelligence can outperform standard optimization techniques
It heavily depends on the problem type and optimization criteria whether SI will outperform standard optimization techniques or not. So, I gave it a try to see how it works in our research problem.
The Experiment
Dataset:
a. MNIST (Image based)
b. Chinese MNIST (Image based)
c. Adult Census Income (Tabular based)
d. Bank Marketing (Tabular based)
e. Churn Modelling (Tabular based)
Models used:
Random Forest
Support Vector Machine (SVM)
Optimization Techniques:
Optuna (For comparison)
Bald Eagle Optimization (BEO)
Particle Swarm Optimization (PSO)
Mother Tree Optimization (MTO)
Code
# Baseline model
n_estimators: 100
# Optuna parameters used in-general
n_estimators: (50, 300)
max_depth: (5, 50)
max_trial: 30
# Bald Eagle parameters used in-general
population_size = 10
generations = 30
explore_ratio = 0.5
exploit_ratio = 0.5
# Particle Swarm parameters used in-general
num_particles = 10
num_iterations = 30
w = 0.5
c1 = 1.5
c2 = 1.5
# Mother Tree parameters used in-general
num_trees = 10
num_iterations = 30
alpha = 0.5
beta = 0.3
# Optuna perimeters used for measuring max capability
n_estimators: (50, 300)
max_depth: (5, 50)
max_trial: 50
# Along with PCA and subsampling at 5000 samples
# Bald Eagle parameters used for measuring max capability
population_size = 20
generations = 50
explore_ratio = 0.5
exploit_ratio = 0.5
# Along with PCA and subsampling at 5000 samples
# Particle Swarm parameters used for measuring max capability
num_particles = 20
num_iterations = 50
w = 0.5
c1 = 1.5
c2 = 1.5
# Along with PCA and subsampling at 5000 samples
# Mother Tree parameters used for measuring max capability
num_trees = 20
num_iterations = 50
alpha = 0.5
beta = 0.3
# Along with PCA and subsampling at 5000 samples
For complete code and experiment setup refer GitHub repo of My Neural Path.
The Results
Experiment on MNIST Dataset
Algorithm | Optimization | Accuracy | Time taken |
Random Forest | Baseline | 96.73% | 16sec |
Random Forest | Optuna | 96.91% | 14.4min |
Random Forest | Bald Eagle | 96.99% | 10.4min |
Random Forest | Particle Swarm | 97.17% | 26.7min |
Random Forest | Mother Tree | 97.11% | 19.2min |
SVM | Baseline | 97.64% | 4.1min |
SVM | Optuna | 98.23% | 12.5min |
SVM | Bald Eagle | 94.08% | 4min |
SVM | Particle Swarm | 95.83% | 2min |
SVM | Mother Tree | 93.81% | 12min |
Experiment on Chinese MNIST Dataset
Algorithm | Optimization | Accuracy | TIme taken |
Random Forest | Baseline | 82.07% | 1.25min |
Random Forest | Optuna | 83.26% | 3.25min |
Random Forest | Bald Eagle | 83.37% | 2.10min |
Random Forest | Particle Swarm | 83.9% | 4.40min |
Random Forest | Mother Tree | 75.7% | 3.28min |
SVM | Baseline | 47.5% | 33sec |
SVM | Optuna | 66% | 1min |
SVM | Bald Eagle | 71.8% | 15min |
SVM | Particle Swarm | 30.7% | 9.23min |
SVM | Mother Tree | 84.63% | 13min |
Experiment on Adult Census Income Dataset
Algorithm | Optimization | Accuracy | Time taken |
Random Forest | Baseline | 85.41% | 10sec |
Random Forest | Optuna | 86.08% | 50sec |
Random Forest | Bald Eagle | 85.86% | 2.45min |
Random Forest | Particle Swarm | 86.36% | 2min |
Random Forest | Mother Tree | 86.58% | 2.30min |
SVM | Baseline | 85.28% | 52sec |
SVM | Optuna | 81.10% | 6.10min |
SVM | Bald Eagle | 81.18% | 7.27min |
SVM | Particle Swarm | 81.42% | 8.20min |
SVM | Mother Tree | 79.44% | 10min |
Experiment on Bank Marketing Dataset
Algorithm | Optimization | Accuracy | TIme taken |
Random Forest | Baseline | 89.54% | 16sec |
Random Forest | Optuna | 89.07% | 2.15min |
Random Forest | Bald Eagle | 88.99% | 3.35min |
Random Forest | Particle Swarm | 89.09% | 3.10min |
Random Forest | Mother Tree | 88.41% | 3.45min |
SVM | Baseline | 88.33% | 3sec |
SVM | Optuna | 88.28% | 13sec |
SVM | Bald Eagle | 88.3% | 1.10min |
SVM | Particle Swarm | 88.33% | 1.15min |
SVM | Mother Tree | 88% | 1.07min |
Churn Modelling Dataset
Algorithm | Optimization | Accuracy | TIme taken |
Random Forest | Baseline | 84.83% | 2sec |
Random Forest | Optuna | 80.5% | 2.30min |
Random Forest | Bald Eagle | 80.67% | 5.23min |
Random Forest | Particle Swarm | 81.17% | 4min |
Random Forest | Mother Tree | 79.83% | 20sec |
SVM | Baseline | 80.17% | 2sec |
SVM | Optuna | 79.83% | 20sec |
SVM | Bald Eagle | 79.5% | 29sec |
SVM | Particle Swarm | 79.5% | 27sec |
SVM | Mother Tree | 80% | 21.37min |
Nature-Inspired Optimization Techniques did not perform as expected. The main challenge was their high computational cost, making experimentation difficult. While these techniques produced good accuracy, the computational overhead made them inefficient and impractical for optimizing ML models like SVM and Random Forest. Swarm Intelligence-based optimization techniques outperformed evolutionary algorithms like GWO and BEO but failed to surpass standard optimization methods such as GridSearch or Optuna. In some cases, PSO performed slightly better than Optuna, but the difference was marginal and not justifiable given the computational cost.
What’s Next?
For now, I’m wrapping up my experiments on this research problem. In a few days, I’ll make the work available on arXiv, including statistical validation, code, and visualizations. I might revisit Evolutionary Algorithms another time for further experiments. Right now, I’ve figured out an exciting research problem focused on optimizing MoE-based LLM models, and I’m eager to dive into it. Stay tuned for more updates!
Thanks for reading! If you enjoyed this, follow along in the My Neural Path series for more exciting AI experiments!
Subscribe to my newsletter
Read articles from Anuj Tiwari directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Anuj Tiwari
Anuj Tiwari
I write blogs about AI experimentation, Data analysis, Model-building and CS fundamentals here.