Skip to main content

Based on the paper: J. S. Saravanan and A. Mahadevan, "AI based parameter estimation of ML model using Hybrid of Genetic Algorithm and Simulated Annealing," 2023 14th International Conference on Computing Communication and Networking Technologies (ICCCNT), Delhi, India, 2023, pp. 1-5, doi: 10.1109/ICCCNT56998.2023.10308077.

Hyperparameter Optimization with Genetic Algorithm and Simulated Annealing

This repository contains a Python package jss_optimizer for optimizing hyperparameters using genetic algorithm (GA) and simulated annealing (SA) hybrid optimization algorithm.

Installation

You can install the package using pip:

pip install jss_optimizer

Usage Example

from jss_optimizer.jss_optimizer import HyperparameterOptimizer
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.ensemble import RandomForestClassifier

# Load dataset
df = pd.read_csv('dataset/heart_v2.csv')
X = df.drop('heart disease', axis=1)
y = df['heart disease']
X_train, X_test, y_train, y_test = train_test_split(X, y, train_size=0.7, random_state=42)

# Define model and parameters
model = RandomForestClassifier
params = ['max_depth', 'min_samples_leaf', 'n_estimators']

# Create an instance of HyperparameterOptimizer
optimizer = HyperparameterOptimizer(model, params)

# Optimize hyperparameters using genetic algorithm
best_solution_genetic = optimizer.optimize(X_train, y_train, X_test, y_test)
print('Best solution found by genetic algorithm:', best_solution_genetic)

# NOTE
# Most of the time, genetic algorithm itself could give an optimal solution. But it could also get caught in a local optima. 
# To aviod such senarios, further optimization with simulated annealing is recommended.
# Use the solution that you see fit is optimal.  

# Perform simulated annealing 
best_solution_simulated_annealing = optimizer.simulate_annealing(best_solution_genetic, X_train, y_train, X_test, y_test)
print('Best solution found by GA-SA hybrid optimization algorithm:', best_solution_simulated_annealing)

works are under progress to extend it to work with every data and model in any given senario

Version Logs

version: 0.1.1 - This will work only with Random Forest Classifier on any dataset.

version: 0.1.2 - Same as version: 0.1.1. Added improvements & support for train-test spitting with proper score metrics

Release files for jss-optimizer 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for jss-optimizer 0.1.2
File Size Uploaded
jss_optimizer-0.1.2.tar.gz 6.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for jss-optimizer 0.1.2
File Interpreter ABI Platform
jss_optimizer-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 10.4 kB

Release files / jss_optimizer-0.1.2.tar.gz

Download URL jss_optimizer-0.1.2.tar.gz
Size 6.3 kB
Tags Source
SHA-256 checksum
How to use checksums
8d38ebb23d569c6fb2b51d8ebb3e6337b5a655ce8ff72f1f48dea17d586955c4
BLAKE2b-256 checksum
How to use checksums
2fbdcb5840e5c26311050ec295e021a109e0999649c37641718009b4501f0467
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.8.8

Release files / jss_optimizer-0.1.2-py3-none-any.whl

Download URL jss_optimizer-0.1.2-py3-none-any.whl
Size 4.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
650bf3a473880b11ef90df3e12f324c440f96490c252557a0ba4433a98932d69
BLAKE2b-256 checksum
How to use checksums
f6c391654d25a5a63928273a3c356671c8237835be5fac3ad2cadb2f87350a42
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.8.8

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page