gizai:ml/classify
classification and its helpers.
import * as Classify from "gizai:ml/classify";Types
Partial
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.Modelsgd:M40.Sgdstates:Vec<M40.SgdState>batch:M36.MiniBatchrng:gizlang_random.Random
Functions
labelsOf
function labelsOf(y: Vec<f64>, n: i64): LabelsThe sorted distinct labels of the n rows y, and each row's class index.
Effects: fail.
fit
function fit(task: string, algorithm: string, h: Json, data: Data, seed0: u64): Model throws stringFits algorithm for task with the hyperparameters h (scikit-learn's keyword arguments).
Effects: fail.
streams
function streams(task: string, algorithm: string): boolWhether 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
function partial(task: string, algorithm: string, h: Json, features: i64, targets: i64, classes: Vec<f64>, seed0: u64): Partial throws stringA model of TASK and ALGORITHM that learns batch by batch (partial_fit), with hyperparameters H.
Effects: fail.
resume
function resume(m: Model, h: Json, seed: u64): Partial throws stringA 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
function Partial.feed(self: mut Partial, x: Vec<f64>, y: Vec<f64>, n: i64): bool throws stringLearns from the n rows of x (row-major) and y (targets a row; a class value for a classifier).
Effects: fail.
Partial.result
function Partial.result(self: Partial): ModelThe model learned so far.
Effects: fail.