Skip to main content

ML Fast Opt - Advanced ensemble optimization system for LightGBM hyperparameter tuning

Project description

MLFastOpt

PyPI version Python 3.8+ License: MIT

MLFastOpt is a high-speed ensemble optimization system for Bayesian hyperparameter tuning of LightGBM models.

Features

  • 🚀 Fast Optimization: Advanced Bayesian optimization algorithms.
  • 🎯 LightGBM Focused: Automated ensemble creation and tuning.
  • ⚙️ Simple Config: JSON-based configuration and Python-based search spaces.
  • 📊 Rich Analytics: Built-in web dashboards and visualization tools.

Installation

pip install mlfastopt

Quick Start

Prerequisite: Input data must be preprocessed and numerical. Handle all categorical encoding (e.g., one-hot, label encoding) before using MLFastOpt.

1. Setup

Create the required directory structure:

mkdir -p config/hyperparameters data

2. Define Parameter Space

Create config/hyperparameters/my_space.py:

PARAMETERS = [
    {"name": "num_leaves", "type": "range", "bounds": [20, 200], "value_type": "int"},
    {"name": "learning_rate", "type": "range", "bounds": [0.01, 0.3], "value_type": "float", "log_scale": True},
    {"name": "n_estimators", "type": "range", "bounds": [100, 300], "value_type": "int"},
    # Add other LightGBM parameters as needed
]

def get_parameter_space():
    return PARAMETERS

3. Configure

Create my_config.json:

{
  "DATA_PATH": "data/your_dataset.parquet",
  "HYPERPARAMETER_PATH": "config/hyperparameters/my_space.py",
  "LABEL_COLUMN": "target",
  "FEATURES": ["feature1", "feature2"],
  "N_ENSEMBLE_GROUP_NUMBER": 5,
  "AE_NUM_TRIALS": 20,
  "PARALLEL_TRAINING": true,
  "N_JOBS": -1
}

4. Run

Execute optimization (ensure single-threading for LightGBM to avoid deadlocks):

export OMP_NUM_THREADS=1
python -m mlfastopt.cli --config my_config.json

Configuration Reference

Parameter Description Default
DATA_PATH Path to dataset (CSV/Parquet). Required
HYPERPARAMETER_PATH Path to parameter space file. Required
LABEL_COLUMN Name of target column. Required
FEATURES List of feature names. Required
N_ENSEMBLE_GROUP_NUMBER Models per ensemble. 1
AE_NUM_TRIALS Total optimization trials. 20
NUM_SOBOL_TRIALS Initial random trials. 5
OPTIMIZATION_METRICS Metric to maximize (soft_recall, soft_f1_score, etc). soft_recall
SAVE_THRESHOLD_ENABLED Save only models exceeding metric threshold. false
ENABLE_DATA_IMPUTATION Simple median/mode imputation. false

Outputs

Results are saved to outputs/:

  • runs/: Detailed logs and models for each run.
  • best_trials/: JSON configurations of the best performing trials.
  • visualizations/: Generated plots.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mlfastopt-0.0.9b1.tar.gz (58.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mlfastopt-0.0.9b1-py3-none-any.whl (63.1 kB view details)

Uploaded Python 3

File details

Details for the file mlfastopt-0.0.9b1.tar.gz.

File metadata

  • Download URL: mlfastopt-0.0.9b1.tar.gz
  • Upload date:
  • Size: 58.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.11

File hashes

Hashes for mlfastopt-0.0.9b1.tar.gz
Algorithm Hash digest
SHA256 99f2f1bf94b539b1c4d47c5ea4a679bfd14faebca040be803a0ebedde72ff356
MD5 5617d910e312211bceaf40d39a5071ea
BLAKE2b-256 a253dce938e3a2238d16799b0712bcb65df25865b144eaf478d3fa074516a896

See more details on using hashes here.

File details

Details for the file mlfastopt-0.0.9b1-py3-none-any.whl.

File metadata

  • Download URL: mlfastopt-0.0.9b1-py3-none-any.whl
  • Upload date:
  • Size: 63.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.11

File hashes

Hashes for mlfastopt-0.0.9b1-py3-none-any.whl
Algorithm Hash digest
SHA256 f952ed21fbada8c37aea4b627ddd8fcf85eb207ef6b4e293efa0812af76be39c
MD5 145589549751d30f1664098eed16af10
BLAKE2b-256 c9a001c2e299ac05800c2836dfd46da9f654da362aad21a3a09ac504493e2dcf

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page