Skip to main content

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.

Metadata

Release files for marsopt 0.2.0

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

Source distribution (sdist)

Source distribution for marsopt 0.2.0
File Size Uploaded
marsopt-0.2.0.tar.gz 317.7 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for marsopt 0.2.0
File
marsopt-0.2.0-cp313-cp313-win_amd64.whl CPython 3.13 CPython 3.13 Windows x86-64 Details
marsopt-0.2.0-cp313-cp313-musllinux_1_2_x86_64.whl CPython 3.13 CPython 3.13 Linux musl 1.2+ x86-64 Details
marsopt-0.2.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.17+ x86-64 Details
marsopt-0.2.0-cp313-cp313-macosx_11_0_arm64.whl CPython 3.13 CPython 3.13 macOS 11.0+ ARM64 Details
marsopt-0.2.0-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details
marsopt-0.2.0-cp312-cp312-musllinux_1_2_x86_64.whl CPython 3.12 CPython 3.12 Linux musl 1.2+ x86-64 Details
marsopt-0.2.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.17+ x86-64 Details
marsopt-0.2.0-cp312-cp312-macosx_11_0_arm64.whl CPython 3.12 CPython 3.12 macOS 11.0+ ARM64 Details
marsopt-0.2.0-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details
marsopt-0.2.0-cp311-cp311-musllinux_1_2_x86_64.whl CPython 3.11 CPython 3.11 Linux musl 1.2+ x86-64 Details
marsopt-0.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.17+ x86-64 Details
marsopt-0.2.0-cp311-cp311-macosx_11_0_arm64.whl CPython 3.11 CPython 3.11 macOS 11.0+ ARM64 Details

Total release size: 14.6 MB

Release files / marsopt-0.2.0.tar.gz

Download URL marsopt-0.2.0.tar.gz
Size 317.7 kB
Tags Source
SHA-256 checksum
How to use checksums
74e25f24a36ca56f5801ba11fd617650753a75a363021072366bc78fea4c44f8
BLAKE2b-256 checksum
How to use checksums
ee50d38ae49e7957d6fde9b19edd3d0b7cb1b2ad28f9f409c8edf86852d04383
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Release files / marsopt-0.2.0-cp313-cp313-win_amd64.whl

Download URL marsopt-0.2.0-cp313-cp313-win_amd64.whl
Size 472.8 kB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
a835f94e13659e22edefd890e47037abfd7972af4630a8184ccc018f7488f1ba
BLAKE2b-256 checksum
How to use checksums
8eb08629d6979e84435c4f59bc441e94efd8c8892e1279fd031d59f5f2b02770
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Release files / marsopt-0.2.0-cp313-cp313-musllinux_1_2_x86_64.whl

Download URL marsopt-0.2.0-cp313-cp313-musllinux_1_2_x86_64.whl
Size 2.4 MB
Tags CPython 3.13 Linux musl 1.2+ x86-64
SHA-256 checksum
How to use checksums
69d7d087e41e15f26210a95b935110699c4ca9f67e8067ca3235269d7c20fedc
BLAKE2b-256 checksum
How to use checksums
f231234d3f4fd4ac4613f39c454a0b33f2ab02d209977fae6d2c00f04270a5bc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Release files / marsopt-0.2.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL marsopt-0.2.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 1.4 MB
Tags CPython 3.13 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
9650a6ee6eebcf82763d34a9a08d2103c1335c2322cae1089287f2a78b2926ac
BLAKE2b-256 checksum
How to use checksums
22263e13c853574a05e2757660bca5eec3531e16df4e266fa38bcb1b117b85e2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Release files / marsopt-0.2.0-cp313-cp313-macosx_11_0_arm64.whl

Download URL marsopt-0.2.0-cp313-cp313-macosx_11_0_arm64.whl
Size 467.6 kB
Tags CPython 3.13 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
34f67c3f4d558977478379247db2af80bfa2006d1a3eaf6c9ebf4c1e9cc922e4
BLAKE2b-256 checksum
How to use checksums
8cfc7ffabade97209bda8f871e0dab050d4a09bda4697825e01068678e034d83
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Release files / marsopt-0.2.0-cp312-cp312-win_amd64.whl

Download URL marsopt-0.2.0-cp312-cp312-win_amd64.whl
Size 472.7 kB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
88954a6a75e46ad050129138f891ac6002b33524a460be3ceda09571476cae6c
BLAKE2b-256 checksum
How to use checksums
28eb82a84f32ea9e70d96cf3497e83278869c0d9c1efe07132bcf543f5dcdbda
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Release files / marsopt-0.2.0-cp312-cp312-musllinux_1_2_x86_64.whl

Download URL marsopt-0.2.0-cp312-cp312-musllinux_1_2_x86_64.whl
Size 2.4 MB
Tags CPython 3.12 Linux musl 1.2+ x86-64
SHA-256 checksum
How to use checksums
7e5e1baf86c339e365d1410ba29eeea7e49e6146da3e93dc6911469b0bb88c15
BLAKE2b-256 checksum
How to use checksums
0a7cfa0bc11bf4ec777cd3b6fe4f4791fb883a6b699df90d99e4de89cb4c28f9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Release files / marsopt-0.2.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL marsopt-0.2.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 1.4 MB
Tags CPython 3.12 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
d7dfd6718fb19017d2a39a7b24c02f6786a5e836829ec7ec44f8ee039ccc8974
BLAKE2b-256 checksum
How to use checksums
a5796f1c3472181d40b569558158131e53839a8deaceb386ab5a44012428e6a1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Release files / marsopt-0.2.0-cp312-cp312-macosx_11_0_arm64.whl

Download URL marsopt-0.2.0-cp312-cp312-macosx_11_0_arm64.whl
Size 469.0 kB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
0bfd3de565a2ddfde473782500040f3fd1a763dc8735eaed77f60e1e9e75f6ac
BLAKE2b-256 checksum
How to use checksums
db80a9040b8aa838623e437af6ad18d3143ed6ab9022c3154d1e9888b640a528
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Release files / marsopt-0.2.0-cp311-cp311-win_amd64.whl

Download URL marsopt-0.2.0-cp311-cp311-win_amd64.whl
Size 474.9 kB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
4215ce2711aa84be702091632b7510c0fb2a2e35c856d4eaf04ef4c5c8d8f4a9
BLAKE2b-256 checksum
How to use checksums
6169369e8d8dd666389ccc6dca85f2a508b8e242381aed3166408ea336738f05
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Release files / marsopt-0.2.0-cp311-cp311-musllinux_1_2_x86_64.whl

Download URL marsopt-0.2.0-cp311-cp311-musllinux_1_2_x86_64.whl
Size 2.4 MB
Tags CPython 3.11 Linux musl 1.2+ x86-64
SHA-256 checksum
How to use checksums
6d7beb3a1d141a3dd993d4659c6ee14984706cb8e5d4b1b518dd3ef79c32af22
BLAKE2b-256 checksum
How to use checksums
60e196fd18a71714f9258b506c229dd2a887c962a6a9ac309ffa4b20fe757404
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Release files / marsopt-0.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL marsopt-0.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 1.4 MB
Tags CPython 3.11 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
2063cf72b6b47bcc8d2ef505fa5b605f20d292cad485c2e633457c4eade3c99d
BLAKE2b-256 checksum
How to use checksums
6f6b097bf7440b06c4e1bc349a31ae6c0893b165a29d3fcb7998d91730806613
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Release files / marsopt-0.2.0-cp311-cp311-macosx_11_0_arm64.whl

Download URL marsopt-0.2.0-cp311-cp311-macosx_11_0_arm64.whl
Size 470.7 kB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
c1d598e9ae32277a3d0ffbce9f5093ff71c9a3c8c82ed71688d8b051ac71023a
BLAKE2b-256 checksum
How to use checksums
1c7de149d172596ca6a5eb95bfabc1cea668ba661f2aad62e18889f06f5e48e5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Release history Release notifications | RSS feed

This release

0.2.0 This release

13 release files

0.1.1

2 release files

0.1.0

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