Skip to main content

Mixed Adaptive Random Search for Optimization

Project description

marsopt logo

marsopt

Mixed Adaptive Random Search for Optimization

PyPI version License Python Versions

marsopt is a Python library designed to simplify and accelerate hyperparameter and black-box optimization. It supports continuous, integer, and categorical variables. Based on Mixed Adaptive Random Search (MARS) algorithm, marsopt dynamically balances exploration and exploitation through:

  • adaptive noise for sampling,
  • elite selection to guide the search toward promising regions,
  • flexible handling of log-scale and categorical parameters,
  • minimization or maximization of any user-defined objective.

MARS iteratively refines a population of “elite” solutions and generates new candidates by perturbing those elites with gradually decreasing noise. For a more detailed explanation of MARS, see our algorithm overview in the documentation.

Features

  • Mixed Variable Support: Optimize integer, float (with optional log-scale), and categorical variables in the same study.
  • Adaptive Sampling: Early iterations explore widely, while later iterations exploit the best regions found, thanks to a built-in cosine annealing scheme for noise.
  • Easy Setup: Simply define an objective function, specify a variable search space, and run study.optimize().
  • Resume & Extend: Continue a Study with more trials at any time without losing past information.
  • Rich Tracking: Inspect all trial details (objective values, parameters, times, and so on) for deeper analysis.

Installation

Install marsopt from PyPI:

pip install marsopt

Getting Started

Below is a simplified example of how to use marsopt to tune a few common hyperparameters:

from marsopt import Study, Trial
import numpy as np

def objective(trial: Trial) -> float:
    lr = trial.suggest_float("learning_rate", 1e-4, 1e-1, log=True)
    layers = trial.suggest_int("num_layers", 1, 5)
    optimizer = trial.suggest_categorical("optimizer", ["adam", "sgd", "rmsprop"])

    score = -5 * (np.log10(lr) + 3) ** 2  
    score += np.log1p(layers) * 10  
    score += {"adam": 15, "sgd": 5, "rmsprop": 20}[optimizer]

    return -score

# Run optimization
study = Study(direction="minimize", random_state=42)
study.optimize(objective, n_trials=50)

Documentation

For more detailed information about the API and advanced usage, please refer to the full documentation.

Contributing

Contributions are welcome! If you'd like to improve marsopt or suggest new features, feel free to fork the repository and submit a pull request.

License

This project is licensed under the MIT License.

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

marsopt-0.2.0.tar.gz (317.7 kB view details)

Uploaded Source

Built Distributions

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

marsopt-0.2.0-cp313-cp313-win_amd64.whl (472.8 kB view details)

Uploaded CPython 3.13Windows x86-64

marsopt-0.2.0-cp313-cp313-musllinux_1_2_x86_64.whl (2.4 MB view details)

Uploaded CPython 3.13musllinux: musl 1.2+ x86-64

marsopt-0.2.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

marsopt-0.2.0-cp313-cp313-macosx_11_0_arm64.whl (467.6 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

marsopt-0.2.0-cp312-cp312-win_amd64.whl (472.7 kB view details)

Uploaded CPython 3.12Windows x86-64

marsopt-0.2.0-cp312-cp312-musllinux_1_2_x86_64.whl (2.4 MB view details)

Uploaded CPython 3.12musllinux: musl 1.2+ x86-64

marsopt-0.2.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

marsopt-0.2.0-cp312-cp312-macosx_11_0_arm64.whl (469.0 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

marsopt-0.2.0-cp311-cp311-win_amd64.whl (474.9 kB view details)

Uploaded CPython 3.11Windows x86-64

marsopt-0.2.0-cp311-cp311-musllinux_1_2_x86_64.whl (2.4 MB view details)

Uploaded CPython 3.11musllinux: musl 1.2+ x86-64

marsopt-0.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

marsopt-0.2.0-cp311-cp311-macosx_11_0_arm64.whl (470.7 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

File details

Details for the file marsopt-0.2.0.tar.gz.

File metadata

  • Download URL: marsopt-0.2.0.tar.gz
  • Upload date:
  • Size: 317.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for marsopt-0.2.0.tar.gz
Algorithm Hash digest
SHA256 74e25f24a36ca56f5801ba11fd617650753a75a363021072366bc78fea4c44f8
MD5 2eabb7e8633c8e8110c2b31d46849e6b
BLAKE2b-256 ee50d38ae49e7957d6fde9b19edd3d0b7cb1b2ad28f9f409c8edf86852d04383

See more details on using hashes here.

File details

Details for the file marsopt-0.2.0-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: marsopt-0.2.0-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 472.8 kB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for marsopt-0.2.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 a835f94e13659e22edefd890e47037abfd7972af4630a8184ccc018f7488f1ba
MD5 86de695b20ec98b3aeb8f7636fa4b76f
BLAKE2b-256 8eb08629d6979e84435c4f59bc441e94efd8c8892e1279fd031d59f5f2b02770

See more details on using hashes here.

File details

Details for the file marsopt-0.2.0-cp313-cp313-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for marsopt-0.2.0-cp313-cp313-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 69d7d087e41e15f26210a95b935110699c4ca9f67e8067ca3235269d7c20fedc
MD5 7ee94c2d3a9ed651beda371281cc2cdf
BLAKE2b-256 f231234d3f4fd4ac4613f39c454a0b33f2ab02d209977fae6d2c00f04270a5bc

See more details on using hashes here.

File details

Details for the file marsopt-0.2.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for marsopt-0.2.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9650a6ee6eebcf82763d34a9a08d2103c1335c2322cae1089287f2a78b2926ac
MD5 428fb244462cd432f23a54e54996bcb0
BLAKE2b-256 22263e13c853574a05e2757660bca5eec3531e16df4e266fa38bcb1b117b85e2

See more details on using hashes here.

File details

Details for the file marsopt-0.2.0-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for marsopt-0.2.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 34f67c3f4d558977478379247db2af80bfa2006d1a3eaf6c9ebf4c1e9cc922e4
MD5 704197674267146b74c5a62da15fd831
BLAKE2b-256 8cfc7ffabade97209bda8f871e0dab050d4a09bda4697825e01068678e034d83

See more details on using hashes here.

File details

Details for the file marsopt-0.2.0-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: marsopt-0.2.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 472.7 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for marsopt-0.2.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 88954a6a75e46ad050129138f891ac6002b33524a460be3ceda09571476cae6c
MD5 5e9b83cc5588ae22e5e1ba4f4bfef4cc
BLAKE2b-256 28eb82a84f32ea9e70d96cf3497e83278869c0d9c1efe07132bcf543f5dcdbda

See more details on using hashes here.

File details

Details for the file marsopt-0.2.0-cp312-cp312-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for marsopt-0.2.0-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 7e5e1baf86c339e365d1410ba29eeea7e49e6146da3e93dc6911469b0bb88c15
MD5 5b1238370a0af9f259488670ffad7f65
BLAKE2b-256 0a7cfa0bc11bf4ec777cd3b6fe4f4791fb883a6b699df90d99e4de89cb4c28f9

See more details on using hashes here.

File details

Details for the file marsopt-0.2.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for marsopt-0.2.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d7dfd6718fb19017d2a39a7b24c02f6786a5e836829ec7ec44f8ee039ccc8974
MD5 fde027e869cbbab413e8eb68e2f4ad52
BLAKE2b-256 a5796f1c3472181d40b569558158131e53839a8deaceb386ab5a44012428e6a1

See more details on using hashes here.

File details

Details for the file marsopt-0.2.0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for marsopt-0.2.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0bfd3de565a2ddfde473782500040f3fd1a763dc8735eaed77f60e1e9e75f6ac
MD5 b483007f01e67705266aeb6a405ed228
BLAKE2b-256 db80a9040b8aa838623e437af6ad18d3143ed6ab9022c3154d1e9888b640a528

See more details on using hashes here.

File details

Details for the file marsopt-0.2.0-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: marsopt-0.2.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 474.9 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for marsopt-0.2.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 4215ce2711aa84be702091632b7510c0fb2a2e35c856d4eaf04ef4c5c8d8f4a9
MD5 42dbd64e4660fcf175d8e05c2c84af5e
BLAKE2b-256 6169369e8d8dd666389ccc6dca85f2a508b8e242381aed3166408ea336738f05

See more details on using hashes here.

File details

Details for the file marsopt-0.2.0-cp311-cp311-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for marsopt-0.2.0-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 6d7beb3a1d141a3dd993d4659c6ee14984706cb8e5d4b1b518dd3ef79c32af22
MD5 e6e6f037f8444c606b843065bb35e22b
BLAKE2b-256 60e196fd18a71714f9258b506c229dd2a887c962a6a9ac309ffa4b20fe757404

See more details on using hashes here.

File details

Details for the file marsopt-0.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for marsopt-0.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2063cf72b6b47bcc8d2ef505fa5b605f20d292cad485c2e633457c4eade3c99d
MD5 2659458656ba08b766b50f76a74313a8
BLAKE2b-256 6f6b097bf7440b06c4e1bc349a31ae6c0893b165a29d3fcb7998d91730806613

See more details on using hashes here.

File details

Details for the file marsopt-0.2.0-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for marsopt-0.2.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c1d598e9ae32277a3d0ffbce9f5093ff71c9a3c8c82ed71688d8b051ac71023a
MD5 66e8ba46f53f5461698ec23933b86f8d
BLAKE2b-256 1c7de149d172596ca6a5eb95bfabc1cea668ba661f2aad62e18889f06f5e48e5

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