# gizai:ml/classify

classification and its helpers.

```gizlang
import * as Classify from "gizai:ml/classify";
```

## Types

### `Partial`

```gizlang
type Partial = { model: Model; sgd: Sgd; states: Vec<SgdState>; batch: MiniBatch; rng: Random; }
```

A model that learns one batch of rows at a time, as scikit-learn's partial_fit: one pass of SGD over each batch, or
one step of mini-batch k-means. A classifier takes its classes before the first batch.

- `model`: `M42.Model`
- `sgd`: `M40.Sgd`
- `states`: `Vec<M40.SgdState>`
- `batch`: `M36.MiniBatch`
- `rng`: `gizlang_random.Random`

## Functions

### `labelsOf`

```gizlang
function labelsOf(y: Vec<f64>, n: i64): Labels
```

The sorted distinct labels of the `n` rows `y`, and each row's class index.

Effects: fail.

### `fit`

```gizlang
function fit(task: string, algorithm: string, h: Json, data: Data, seed0: u64): Model throws string
```

Fits `algorithm` for `task` with the hyperparameters `h` (scikit-learn's keyword arguments).

Effects: fail.

### `streams`

```gizlang
function streams(task: string, algorithm: string): bool
```

Whether `algorithm` of `task` learns one batch at a time (Partial): the SGD models and mini-batch k-means. The
others need all their rows at once.

Effects: fail.

### `partial`

```gizlang
function partial(task: string, algorithm: string, h: Json, features: i64, targets: i64, classes: Vec<f64>, seed0: u64): Partial throws string
```

A model of TASK and ALGORITHM that learns batch by batch (partial_fit), with hyperparameters H.

Effects: fail.

### `resume`

```gizlang
function resume(m: Model, h: Json, seed: u64): Partial throws string
```

A Partial that goes on from `m`, an SGD model (scikit-learn's warm_start: its weights, the step count again 1).

Effects: fail.

## Methods

### `Partial.feed`

```gizlang
function Partial.feed(self: mut Partial, x: Vec<f64>, y: Vec<f64>, n: i64): bool throws string
```

Learns from the `n` rows of x (row-major) and y (`targets` a row; a class value for a classifier).

Effects: fail.

### `Partial.result`

```gizlang
function Partial.result(self: Partial): Model
```

The model learned so far.

Effects: fail.

