skillfed

better-optimize

A drop-in replacement for scipy optimize functions with quality of life improvements

better-optimize v0.4.2 206.4K downloads/30d#9,574 on PyPI7
Permissive license MIT License Active released

What it is and what it does

better_optimize is a convenience layer over scipy's optimization routines that reduces boilerplate and adds visibility into long-running solves. It replaces scipy's nested `options` dictionaries with flat keyword arguments, normalizes callback signatures across different optimizers (minimize, root, basinhopping, differential_evolution), and provides optional rich progress bars showing iteration counts, elapsed time, objective values, and gradient/Hessian norms. It also handles fused objective functions that return multiple values (loss, gradient, Hessian) together, caching intermediate results to avoid redundant computation.

The package includes multi_optimize for parallel optimization from multiple starting points using different initialization strategies (uniform, normal, Sobol, Latin hypercube) and backends (sequential, loky, threading). It depends on numpy, scipy, rich, joblib, pandas, and threadpoolctl. Early stopping is supported by raising StopOptimization from a callback, and all results are standard scipy OptimizeResult objects, so downstream code needs no changes.

Use it for:

  • Minimize a function with a live progress bar to monitor convergence without blocking output.
  • Run the same callback logic across minimize, root, and basinhopping without rewriting for each method's signature.
  • Optimize a triple-fused objective that computes value, gradient, and Hessian together, avoiding redundant computation.
  • Search for the global minimum by launching many local optimizations in parallel from random starting points.
  • Stop an optimization early when a target loss is reached, returning the best result so far.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

A wrapper around scipy's optimize.minimize and optimize.root that adds progress bars, early stopping, flattened keyword arguments, and a unified callback API across different optimization methods.

Yes, if you regularly use scipy's optimize functions and want cleaner syntax, progress visibility, and unified callbacks. The low install friction, active maintenance, permissive license, and zero known vulnerabilities make it a safe addition. Best suited for interactive work and research; production code that calls scipy directly may not need the wrapper overhead.

Install

better-optimize on PyPI

pip

pip install better-optimize

uv

uv add better-optimize

poetry

poetry add better-optimize

Installing better-optimize

Before you install

Low friction: pure Python wheel with standard scientific dependencies (numpy, scipy, rich, joblib, pandas, threadpoolctl). Active maintenance with recent releases.

License in practice

MIT License permits commercial and private use with minimal restrictions; attribution required but no copyleft obligations.

Quickstart

pip install better_optimize

import numpy as np
from better_optimize import minimize

def rosenbrock(x):
    return sum(100.0*(x[1:] - x[:-1]**2.0)**2.0 + (1 - x[:-1])**2.0)

result = minimize(
    rosenbrock,
    x0=np.array([-1.0, 2.0]),
    method="L-BFGS-B",
    tol=1e-6,
    maxiter=1000,
    progressbar=True,
)

Requires Python 3.12 or later.

Verify before relying

  • Whether progress bar display works correctly in all headless/non-terminal environments as claimed.
  • Performance overhead of the wrapper layer relative to direct scipy calls for large-scale problems.
  • Compatibility of fused function detection with all scipy optimizer variants.

Package facts

License MIT License (permissive)
Python support supports the current Python release (>=3.12)
Install friction low — pure-Python wheel
Runtime dependencies 6 — numpy, scipy, rich, threadpoolctl, joblib, pandas
Maintenance actively maintained — 83 days since the last release
Last repo commit
First released
Downloads 206,389/month — #9,574 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: better_optimize-0.4.2-py3-none-any.whl

Development Status :: 4 - BetaIntended Audience :: Science/ResearchLicense :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Topic :: Scientific/EngineeringTopic :: Scientific/Engineering :: Mathematics

Tags

scipy optimize wrapperoptimization progress barminimize with early stoppingscipy minimize alternativeoptimization callback unifiedbasinhopping progress trackingparallel optimization multiple starts
optimization-wrapperscipy-convenienceparallel-search

More Scientific/Engineering packages