Repository navigation
New
pycse.sklearn.mip: export trained piecewise-linear models as mixed-integer linear
constraints in Pyomo, to use them as surrogates inside an optimization problem.
to_pyomo(input_bounds=..., block=..., inputs=...)is available onDPOSE,
LLPRRegressor,NNBR,JAXICNNRegressorandJAXMonotonicRegressor(with the ReLU
activation),KANandKANLLPR(withspline_order=1, base_activation="linear"),
LeafModelRegressor(with a linear leaf model) andLinearRegressionUQ. Models with
uncertainty also export the predictive variance as a second-order cone, somean + k * std
can be optimized with a MISOCP solver.to_pyomo(formulation="convex")exports an
input-convex network (ICNN, orJAXMonotonicRegressor(convexity="convex")) as an LP
without binaries, for minimization. Install withpip install "pycse[mip]".include_std=Trueaddsblock.stdas a second-order cone (exact when the objective
penalizes the std, e.g. robust design);include_std="exact"makes it an equality for
objectives that reward it (e.g. exploration).JAXPeriodicRegressor(activation="relu")exports approximately: its sin/cos features
are interpolated (to_pyomo(points_per_period=...)), with a bound on the error
(mip_network().max_feature_error(bounds)).SISSOandSISSOEnsembleexport their equations as exact nonlinear Pyomo
expressions, for a global MINLP solver.LeafModelRegressor.to_pyomo(split_gap=...)keeps points on a split in the left leaf.- A new page in the documentation, "Optimizing over machine-learned models with MIP",
walks through all of these.
KfoldNN(activation=...)chooses the hidden activation ("swish", the default,
"relu"or"tanh").LLPRRegressorhas new options:calibration("auto","holdout"or"cv") withcv
folds,standardize,warm_startfor refitting in an active learning loop, andverbose.
ReLU and tanh networks export the mean prediction withget_dense_layers(),to_onnx()
andto_omlt()(these needonnxandomlt, which are not installed by any extra).
Changed
-
LLPRRegressorgives different results with the same code:- It standardizes X and y internally (
standardize=True); predictions, uncertainties and
alpha_squared_are in the original units of y. - The last-layer features include a constant, so the output bias contributes to the
uncertainty and the std is never zero (before, a point where every last-layer ReLU was
off got σ = 0). - With fewer than 100 samples,
calibration="auto"calibrates on K-fold out-of-fold
residuals and trains the final model on all the data, so a fit trainscv + 1networks.
α² is the NLL-optimal value in closed form, and ζ² is searched relative to
trace(FᵀF) / n_features. - The last partial batch is used, so datasets smaller than
batch_sizetrain. - It no longer prints during
fit()unlessverbose=True. - The predictive variance is no longer recompiled on every call, so
predict()is faster.
- It standardizes X and y internally (
-
Dependency updates in
uv.lock: certifi, filelock, mcp, nbconvert, pillow 13 and
setuptools. -
KAN.to_pyomo()uses the shared MIP module. The exported model is exact outside the spline
grid (the grid clipping was not represented before), needs one set of segment binaries per
input instead of per edge, and supportsn_ensemble > 1(the ensemble mean, with its std).
Withoutinput_bounds, the inputs are bounded by the range the spline grid covers in data
units instead of bygrid_rangeitself.