Skip to content

Metaheuristic hyperparameter tuning for CNN-based Twitter sentiment analysis — PSO, ACO, Bat Algorithm, Hill Climb, Simulated Annealing, Tabu.

Notifications You must be signed in to change notification settings

aadhamashraf/MetaOpt-CNN-for-Twitter-Sentiment-Classification

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MetaOpt-CNN for Twitter Sentiment Classification

Metaheuristic hyperparameter optimization for CNN-based Twitter sentiment analysis. This project provides a modular Python package to preprocess tweet data, build and evaluate CNN models, and optimize both model and optimizer hyperparameters using multiple metaheuristic algorithms.

Features

  • Two-phase optimization:
    • Phase 1: Optimize CNN hyperparameters (HC, PSO, SA, Tabu)
    • Phase 2: Optimize metaheuristic hyperparameters (ACO, Bat Algorithm, internal tuning)
  • Tokenization and preprocessing pipeline (NLTK)
  • Modular optimizers (each algorithm in its own module)
  • CLI with configurable hyperparameter ranges and algorithm settings
  • Unit tests (pytest) and CI workflow (GitHub Actions)
  • Docker support for reproducible runs
  • JSON logging for experiment tracking and analysis tools

Quick Start

  1. Clone the repo: git clone https://github.com/aadhamashraf/MetaOpt-CNN-for-Twitter-Sentiment-Classification.git
  2. Install dependencies: pip install -r requirements.txt
  3. Run Phase 1 (example): python main.py --phase 1 --csv path/to/twitter_training.csv
  4. Run Phase 2 (example): python main.py --phase 2 --csv path/to/twitter_training.csv

CLI

  • --phase [1|2] : Choose optimization phase
  • --csv PATH : Path to dataset CSV (defaults to twitter_training.csv)
  • --search-space-file PATH : JSON file with hyperparameter ranges
  • --pso-particles N
  • --pso-iters N
  • --hc-iters N
  • --sa-iters N
  • --ts-iters N
  • --aco-ants N
  • --aco-iters N
  • --ba-bats N
  • --ba-iters N

(See main.py --help for full list)

Project Structure

  • src/
    • config.py
    • logger.py
    • data.py
    • cnn.py
    • optimizers/
      • init.py
      • aco.py
      • bat.py
      • pso.py
      • hill_climb.py
      • simulated_annealing.py
      • tabu.py
      • tuner.py
    • run_phase1.py
    • run_phase2.py
    • analyze.py
  • tests/
  • Dockerfile
  • requirements.txt
  • README.md

Logs are written to optimization_log.json by default.

About

Metaheuristic hyperparameter tuning for CNN-based Twitter sentiment analysis — PSO, ACO, Bat Algorithm, Hill Climb, Simulated Annealing, Tabu.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published