# gizai:ml/model

The ML model shape; training and prediction both depend on these types.

```gizlang
import * as Model from "gizai:ml/model";
```

## Types

### `Estimator`

```gizlang
type Estimator = | { kind: "linear"; w: Vec<f64>; outputs: i64; } | { kind: "trees"; ensemble: Ensemble; } | { kind: "svm"; svm: Svm; } | { kind: "centers"; centers: Centers; } | { kind: "project"; mean: Vec<f64>; components: Vec<f64>; outputs: i64; }
```

linear: outputs × (features + 1) weights, the intercept last. project: (x - mean) · each component.

- `linear`
- `trees`
- `svm`
- `centers`
- `project`

### `Model`

```gizlang
type Model = { task: string; algorithm: string; features: i64; targets: i64; classes: Vec<f64>; link: string; parts: Vec<Estimator>; explained: Vec<f64>; }
```

The outputs of a row are those of each part in order. link (classification): logistic (one raw score), softmax (a
raw score per class), proba (probabilities), samme (AdaBoost votes) or scores (no probabilities: the sign of one
score, else the largest). classes: the label of each class index. explained: PCA's explained variance ratios.

- `task`: `string`
- `algorithm`: `string`
- `features`: `i64`
- `targets`: `i64`
- `classes`: `Vec<f64>`
- `link`: `string`
- `parts`: `Vec<M42.Estimator>`
- `explained`: `Vec<f64>`

