GizStack
View .mdOpen in ChatGPTOpen in Claude

gizai:ml/preprocess

A CPU feature pipeline over the native ML data contract. Preprocessing is fit only on training rows and carried alongside the fitted model for inference.

gizlang
import * as Preprocess from "gizai:ml/preprocess";

Types

Standardizer

gizlang
type Standardizer = { features: i64; mean: Vec<f64>; scale: Vec<f64>; }

Training-set-only mean and population standard deviation per feature. A constant column has unit scale so it stays zero after centering.

  • features: i64
  • mean: Vec<f64>
  • scale: Vec<f64>

Pipeline

gizlang
type Pipeline = { transform: Standardizer; model: Model; }

A model with its fitted feature transformation. The two belong together at inference.

  • transform: M44.Standardizer
  • model: M42.Model

Functions

standardizer

gizlang
function standardizer(data: Data): Standardizer throws string

The Standardizer of the training rows of data.

Effects: fail.

fit

gizlang
function fit(task: string, algorithm: string, params: JsonValue, training: Data, seed: u64): Pipeline throws string

Fit the scaler on training rows (never on held-out/test rows), then train.

Effects: fail.

decode

gizlang
function decode(data: bytes): Pipeline throws string

Decode and verify the complete scaler/model bundle before inference.

Effects: fail.

Methods

Standardizer.rows

gizlang
function Standardizer.rows(self: Standardizer, x: Vec<f64>, n: i64): Vec<f64> throws string

Scale one flat row-major matrix, preserving column count and row order.

Effects: fail.

Standardizer.meanShiftZ

gizlang
function Standardizer.meanShiftZ(self: Standardizer, x: Vec<f64>, rows: i64): Vec<f64> throws string

Per-feature absolute shift of a batch's mean, in training standard deviations. A simple numeric diagnostic, not statistical drift detection or an alerting service.

Effects: fail.

Standardizer.data

gizlang
function Standardizer.data(self: Standardizer, input: Data): Data throws string

Transform features only; the training labels are retained unchanged.

Effects: fail.

Pipeline.predict

gizlang
function Pipeline.predict(self: Pipeline, row: Vec<f64>): Vec<f64> throws string

Predict one unscaled feature row with the original training transformation.

Effects: fail.

Pipeline.predictRows

gizlang
function Pipeline.predictRows(self: Pipeline, x: Vec<f64>, rows: i64): Vec<f64> throws string

Predict a batch of unscaled rows without bypassing the transformation.

Effects: fail.

Pipeline.encode

gizlang
function Pipeline.encode(self: Pipeline): bytes throws string

Portable bundle: its fitted scaler and native model bytes share one artifact. JSON is used only for the small manifest and base64-encoded model.

Effects: fail.