v2026.11.0
All Bundles
Bundle

Experiment support for a parameter sweep: a deterministic stratified hold-out split, class-ratio resampling of the training half against a fixed test set, a wall-clock stopwatch and label helpers. Compile with -lib ml,ml_lab,csv,json, or with the ai alias group. Design: docs/ML_LAB_SUPPORT_DESIGN.md.

ResultTable

A table of results: a title, one row per parameter value (a display name and a numeric value), named numeric columns, optional per-cell standard deviations, and a footnote of fixed settings. Renders as aligned text, Markdown, CSV and JSON, and reads CSV and JSON back.

Numbers render with a fixed number of decimals per column (4 by default), so the output is byte-stable; CSV and JSON carry up to 10 decimals with trailing zeros trimmed, so a value survives a round trip to within 1e-10.

Example

t := ResultTable->New("Random forest: trees", "n_estimators");
t->AddColumn("test_accuracy");
t->AddColumn("fit_ms", 1);
t->AddRow("10", 10.0, [0.9412, 12.5]);
t->SetFootnote("max_depth=8; seed=42");
t->ToMarkdown()->PrintLine();
t->Save("rf_trees.csv");

Operations

AddColumn #

Adds a numeric column rendered with 4 decimals. Columns must be added before rows.

method : public : AddColumn(name:String) ~ Nil

Parameters

NameTypeDescription
nameStringcolumn heading

AddColumn #

Adds a numeric column.

method : public : AddColumn(name:String, precision:Int) ~ Nil

Parameters

NameTypeDescription
nameStringcolumn heading
precisionIntdecimals when rendered as text or Markdown

AddRow #

Adds a row without deviations.

method : public : AddRow(name:String, value:Float, cells:Float[]) ~ Nil

Parameters

NameTypeDescription
nameStringthe parameter value's display name
valueFloatthe parameter's numeric value
cellsFloatone value per column

AddRow #

Adds a row with a standard deviation per cell, from repeated runs.

method : public : AddRow(name:String, value:Float, cells:Float[], stds:Float[]) ~ Nil

Parameters

NameTypeDescription
nameStringthe parameter value's display name
valueFloatthe parameter's numeric value
cellsFloatone mean per column
stdsFloatone standard deviation per column, or Nil for none

ColumnIndex #

The index of a column by name.

method : public : ColumnIndex(name:String) ~ Int

Parameters

NameTypeDescription
nameStringcolumn heading

Return

TypeDescription
Intthe index, or -1

FormatNumber # function

A number for CSV and JSON: up to 10 decimals, trailing zeros and a trailing point trimmed, never "-0".

function : FormatNumber(value:Float) ~ String

Parameters

NameTypeDescription
valueFloatthe number

Return

TypeDescription
Stringits text

FromCsv # function

Reads a table written by ToCsv. The title and footnote come back empty.

function : FromCsv(text:String) ~ ResultTable

Parameters

NameTypeDescription
textStringCSV text

Return

TypeDescription
ResultTablethe table; raises LabError when the text is not a ToCsv table

FromJson # function

Reads a table written by ToJson.

function : FromJson(text:String) ~ ResultTable

Parameters

NameTypeDescription
textStringJSON text

Return

TypeDescription
ResultTablethe table; raises LabError when the text is not a ToJson table

Get #

A cell.

method : public : Get(row:Int, col:Int) ~ Float

Parameters

NameTypeDescription
rowIntrow index
colIntcolumn index

Return

TypeDescription
Floatthe value (the mean, for repeated runs)

GetColumn #

One column's values, in row order.

method : public : GetColumn(name:String) ~ Float[]

Parameters

NameTypeDescription
nameStringcolumn heading

Return

TypeDescription
Floatone value per row; raises LabError for an unknown column

GetColumnNames #

Column headings, in order.

method : public : GetColumnNames() ~ String[]

Return

TypeDescription
Stringthe numeric columns' names

GetColumnStds #

One column's standard deviations, in row order.

method : public : GetColumnStds(name:String) ~ Float[]

Parameters

NameTypeDescription
nameStringcolumn heading

Return

TypeDescription
Floatone deviation per row (zeros when the table holds none); raises LabError for an unknown column

GetFootnote #

The footnote.

method : public : GetFootnote() ~ String

Return

TypeDescription
Stringfootnote text, empty when unset

GetParameter #

The swept parameter's name.

method : public : GetParameter() ~ String

Return

TypeDescription
Stringthe first column's heading

GetRowName #

A row's display name.

method : public : GetRowName(row:Int) ~ String

Parameters

NameTypeDescription
rowIntrow index

Return

TypeDescription
Stringthe name

GetRowNames #

The row names, in row order.

method : public : GetRowNames() ~ String[]

Return

TypeDescription
Stringone name per row

GetRowValue #

A row's numeric parameter value.

method : public : GetRowValue(row:Int) ~ Float

Parameters

NameTypeDescription
rowIntrow index

Return

TypeDescription
Floatthe value

GetRowValues #

The parameter values, in row order: the x axis of a chart.

method : public : GetRowValues() ~ Float[]

Return

TypeDescription
Floatone value per row

GetStd #

A cell's standard deviation.

method : public : GetStd(row:Int, col:Int) ~ Float

Parameters

NameTypeDescription
rowIntrow index
colIntcolumn index

Return

TypeDescription
Floatthe deviation, 0.0 when the table holds none

GetTitle #

The title.

method : public : GetTitle() ~ String

Return

TypeDescription
Stringtitle text

HasStds #

Whether any row carries standard deviations.

method : public : HasStds() ~ Bool

Return

TypeDescription
Booltrue after an AddRow with deviations

New # constructor

Constructor

New(title:String, parameter:String)

Parameters

NameTypeDescription
titleStringshown above the table
parameterStringthe swept parameter's name, the first column's heading

Save #

Writes the table in the form the file extension names: .md Markdown, .csv CSV, .json JSON, anything else the aligned text.

method : public : Save(path:String) ~ Bool

Parameters

NameTypeDescription
pathStringfile to write

Return

TypeDescription
Booltrue when written

SetFootnote #

Sets the footnote of fixed settings printed under the table.

method : public : SetFootnote(text:String) ~ Nil

Parameters

NameTypeDescription
textStringthe footnote

Size #

Rows in the table.

method : public : Size() ~ Int

Return

TypeDescription
Introw count

ToChart #

A line chart of named columns against the parameter: x is the parameter value (or the row names as categories when a row name is not its number), one series per metric, error bars from the deviations when the table holds them.

method : public : ToChart(metrics:String[]) ~ Chart

Parameters

NameTypeDescription
metricsStringcolumn names to draw; an empty array draws every column

Return

TypeDescription
Chartthe chart; raises LabError for an unknown column or an empty table

ToChart #

A line chart of named columns, optionally on a log x axis (for C, gamma or a learning rate).

method : public : ToChart(metrics:String[], log_x:Bool) ~ Chart

Parameters

NameTypeDescription
metricsStringcolumn names to draw; an empty array draws every column
log_xBooltrue for a base-10 log x axis

Return

TypeDescription
Chartthe chart; raises LabError for an unknown column or an empty table

ToCsv #

RFC 4180 CSV: a header of the parameter name, "_value", the columns and, when the table holds deviations, "_std" for each; then one record per row. Fields are quoted only when they must be. The title and footnote are not written: a CSV is data, the Markdown and JSON forms carry the prose.

method : public : ToCsv() ~ String

Return

TypeDescription
Stringthe CSV, records ending in LF

ToJson #

JSON, built with Data.JSON: {"title","parameter","footnote","columns":[], "precision":[],"rows":[{"name","value","cells":{column: value}, "stds":{column: deviation}}]}; "stds" is present only when the table holds deviations.

method : public : ToJson() ~ String

Return

TypeDescription
Stringthe JSON text

ToMarkdown #

A GitHub-flavoured Markdown table under a "###" title, the footnote in italics. Deviations render as "mean ± std"; a pipe in a name is escaped.

method : public : ToMarkdown() ~ String

Return

TypeDescription
Stringthe Markdown, lines ending in LF

ToText #

An aligned plain-text table: the title, a header, one line per row, the footnote. Deviations render as "mean +/- std".

method : public : ToText() ~ String

Return

TypeDescription
Stringthe text, lines ending in LF