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.
import * as Preprocess from "gizai:ml/preprocess";Types
Standardizer
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:i64mean:Vec<f64>scale:Vec<f64>
Pipeline
type Pipeline = { transform: Standardizer; model: Model; }A model with its fitted feature transformation. The two belong together at inference.
transform:M44.Standardizermodel:M42.Model
Functions
standardizer
function standardizer(data: Data): Standardizer throws stringThe Standardizer of the training rows of data.
Effects: fail.
fit
function fit(task: string, algorithm: string, params: JsonValue, training: Data, seed: u64): Pipeline throws stringFit the scaler on training rows (never on held-out/test rows), then train.
Effects: fail.
decode
function decode(data: bytes): Pipeline throws stringDecode and verify the complete scaler/model bundle before inference.
Effects: fail.
Methods
Standardizer.rows
function Standardizer.rows(self: Standardizer, x: Vec<f64>, n: i64): Vec<f64> throws stringScale one flat row-major matrix, preserving column count and row order.
Effects: fail.
Standardizer.meanShiftZ
function Standardizer.meanShiftZ(self: Standardizer, x: Vec<f64>, rows: i64): Vec<f64> throws stringPer-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
function Standardizer.data(self: Standardizer, input: Data): Data throws stringTransform features only; the training labels are retained unchanged.
Effects: fail.
Pipeline.predict
function Pipeline.predict(self: Pipeline, row: Vec<f64>): Vec<f64> throws stringPredict one unscaled feature row with the original training transformation.
Effects: fail.
Pipeline.predictRows
function Pipeline.predictRows(self: Pipeline, x: Vec<f64>, rows: i64): Vec<f64> throws stringPredict a batch of unscaled rows without bypassing the transformation.
Effects: fail.
Pipeline.encode
function Pipeline.encode(self: Pipeline): bytes throws stringPortable 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.