Skip to content

API reference — Solvers & optimization

Standalone weighted fitting and the generic bounded optimizer. Guide: Generic optimizer.

fit

fit(X, y, *, family='gaussian', solver='auto', l1=0.0, l2=0.0, sample_weight=None, monotone=None, max_iter=250, tol=1e-09, seed=42, tweedie_p=None, tobit_threshold=None)

Fits a weighted Gaussian or generalized linear model without growing a tree.

Pass one numeric design matrix and one response per row. Use nonnegative case weights with a positive total weight. The solver picks the exact Gaussian path when it fits the family and the requested penalties.

optimize

optimize(objective, bounds, *, method='random_search', start=None, max_evaluations=None, max_iterations=None, tol=1e-06, seed=0, gradient=None, samples=None, initial_population=None, constraints=None, constraint_kind='inequality', local_method=None)

Minimizes a callable scalar objective inside bounds.

The objective receives one list of parameter values and returns one finite scalar. The optional gradient callable receives the same list and returns one value per parameter. Smooth methods use a central-difference fallback when no gradient is supplied. For COBYLA, constraints returns a fixed-length sequence of finite inequality residuals. Nonnegative residuals are feasible. For basin hopping, local_method selects the inner optimizer.

FitResult

class FitResult()

Fitted standalone model from mltreelib.solvers.fit.

Holds the intercept, the coefficient vector, the convergence state, and the statistical summary when the fitted family supports inference statistics.

FitResult.mean_deviance

mean_deviance(self, /, X, y, *, sample_weight=None)

Mean deviance of the fit on one evaluation set.

FitResult.predict

predict(self, /, X)

Predicts the response for one numeric design matrix.

OptimizationResult

class OptimizationResult()

Result of one generic optimization run from mltreelib.solvers.optimize.

Reports the best point, the best objective value, the iteration and evaluation counts, the termination status, and optional convergence history.