# gizai:ml/lbfgs

the L-BFGS optimizer.

```gizlang
import * as Lbfgs from "gizai:ml/lbfgs";
```

## Types

### `Problem`

```gizlang
type Problem = { kind: string; x: Vec<f64>; n: i64; d: i64; y: Vec<f64>; k: i64; reg: f64; epsilon: f64; }
```

logistic: binary log loss (y 0/1), w = d weights + intercept. softmax: k × (d + 1). huber: d weights, intercept,
scale. reg: the L2 strength on the weights.

- `kind`: `string`
- `x`: `Vec<f64>`
- `n`: `i64`
- `d`: `i64`
- `y`: `Vec<f64>`
- `k`: `i64`
- `reg`: `f64`
- `epsilon`: `f64`

## Functions

### `lbfgs`

```gizlang
function lbfgs(p: Problem, w0: Vec<f64>, low: Vec<f64>, maxIter: i64, gtol: f64, ftol: f64): Vec<f64>
```

L-BFGS (10 corrections) with a backtracking Armijo search; `low` bounds each variable from below (projected).

Effects: fail.

### `newtonLogistic`

```gizlang
function newtonLogistic(p: Problem, maxIter: i64, gtol: f64, ftol: f64): Vec<f64>
```

Logistic regression by Newton steps with a backtracking search: with few features the Hessian costs no more than the
gradient, and the steps reach the minimum in a few passes, where L-BFGS on unscaled features stops far from it. Stops
as scikit-learn's lbfgs: the largest gradient entry at most gtol, or a relative loss drop at most ftol.

Effects: fail.

### `lows`

```gizlang
function lows(m: i64): Vec<f64>
```

`m` lower bounds of minus infinity: no bound.

Effects: fail.

