What a student needs to turn a study into a hand-in: Replicates collects the value of each metric per seed and per setting and reports the count, mean, sample standard deviation, range and a t confidence interval, with a paired comparison of two settings; ResultTables converts between a System.ML.Lab ResultTable and the other results (replicates, an OLS fit, t-tests, a grid of strings); Report builds one document with numbered sections, tables, figures, code and notes, written as Markdown or as one self-contained HTML file with a print stylesheet that prints cleanly to PDF from a browser.
No call here ends the program on bad input: a call that cannot do what it was asked returns false (or Nil) and the object keeps the reason, read with GetError(), which is "" when there is nothing to report. Output is deterministic: the same calls give the same bytes, and nothing reads a clock. Compile with -lib ml_report,ml_lab,ml,stats,plot,csv,json,gen_collect.
ReportText
Text helpers shared by the writers: escaping for HTML and Markdown, number formatting, Base64.
Operations
- Base64
- HasHandler
- Html
- IsNumber
- Lines
- LinkPath
- LooksNumeric
- MarkdownCell
- MarkdownLine
- NormalizeNumbers
- NotFinite
- Number
Base64 # function
Base64 of bytes, RFC 4648 with padding.
function : Base64(data:Byte[]) ~ StringParameters
| Name | Type | Description |
|---|---|---|
| data | Byte | the bytes |
Return
| Type | Description |
|---|---|
| String | the encoding, "" for Nil |
HasHandler # function
True when lower-case markup holds an attribute such as onload= or onclick=.
function : HasHandler(lower:String) ~ BoolParameters
| Name | Type | Description |
|---|---|---|
| lower | String | the text in lower case |
Return
| Type | Description |
|---|---|
| Bool | true when an event handler attribute is present |
Html # function
Escapes text for HTML element content or a double-quoted attribute: & < > " and '.
function : Html(text:String) ~ StringParameters
| Name | Type | Description |
|---|---|---|
| text | String | the text, Nil is "" |
Return
| Type | Description |
|---|---|
| String | the escaped text |
IsNumber # function
Parses a plain decimal number; unlike String->ToFloat() it can tell that the text is not one.
function : IsNumber(text:String) ~ BoolParameters
| Name | Type | Description |
|---|---|---|
| text | String | the text |
Return
| Type | Description |
|---|---|
| Bool | true when the whole text is a number |
Lines # function
Splits text into lines; CRLF, CR and LF all end a line. "" is one empty line and Nil is none.
function : Lines(text:String) ~ String[]Parameters
| Name | Type | Description |
|---|---|---|
| text | String | the text |
Return
| Type | Description |
|---|---|
| String | the lines |
LinkPath # function
Percent-encodes the characters of a file path that end a Markdown link target: space, parentheses, angle brackets and percent. Backslashes become slashes.
function : LinkPath(path:String) ~ StringParameters
| Name | Type | Description |
|---|---|---|
| path | String | the path |
Return
| Type | Description |
|---|---|
| String | the encoded path |
LooksNumeric # function
True when the text looks like a number, a number with a deviation or n/a, so a table column of them is right-aligned.
function : LooksNumeric(text:String) ~ BoolParameters
| Name | Type | Description |
|---|---|---|
| text | String | a cell |
Return
| Type | Description |
|---|---|
| Bool | true for numeric-looking text |
MarkdownCell # function
Escapes a table cell or a heading for Markdown: every line escaped as MarkdownLine, joined with an HTML line break because a table row has one line.
function : MarkdownCell(text:String) ~ StringParameters
| Name | Type | Description |
|---|---|---|
| text | String | the text, Nil is "" |
Return
| Type | Description |
|---|---|
| String | the escaped text |
MarkdownLine # function
Escapes one line of text for Markdown so that nothing in it is read as markup: backslash, backtick, asterisk, underscore, brackets, braces, angle brackets, ampersand, pipe, tilde, dollar and caret anywhere, and # - + = or a number and a dot at the start of a line.
function : MarkdownLine(line:String) ~ StringParameters
| Name | Type | Description |
|---|---|---|
| line | String | one line, without a newline |
Return
| Type | Description |
|---|---|
| String | the escaped line, without leading or trailing spaces |
NormalizeNumbers # function
Replaces the spellings of NaN that a number formatter writes with "n/a".
function : NormalizeNumbers(text:String) ~ StringParameters
| Name | Type | Description |
|---|---|---|
| text | String | a formatted cell |
Return
| Type | Description |
|---|---|
| String | the cell with NaN spelled n/a |
NotFinite # function
True for NaN, +Inf and -Inf.
function : NotFinite(v:Float) ~ BoolParameters
| Name | Type | Description |
|---|---|---|
| v | Float | the number |
Return
| Type | Description |
|---|---|
| Bool | true when the number is not finite |
Number # function
A number with a fixed count of decimals; NaN is "n/a", infinities are "inf" and "-inf", and a negative zero is written without its sign.
function : Number(v:Float, decimals:Int) ~ StringParameters
| Name | Type | Description |
|---|---|---|
| v | Float | the number |
| decimals | Int | digits after the point |
Return
| Type | Description |
|---|---|
| String | the text |