statistics.heldOutErrorAt
This function gives the held-out error of a chosen set of points, on the scale of the model. It uses the stored predictions of the option `outOfFold`. Thus a reader can get the error of one cell. The result has the fields of `heldOutError`, and the set of all the points gives the same values to the rounding of the sums.
CLI- Package
- @procedures/statistics · README
- Path
["statistics","heldOutErrorAt"]- CLI
mark statistics heldOutErrorAt --record <object> --measure <string> --ids <string[]>- As data
{"$proc":["statistics","heldOutErrorAt"],"input":{}}
Use it
In TypeScript
import { Client, LocalTransport, PROCEDURE_REGISTRY } from "@procedures/client";
import "@procedures/statistics/register"; // registers its procedures
const client = new Client(new LocalTransport({ registry: PROCEDURE_REGISTRY }));
const result = await client.exec(["statistics","heldOutErrorAt"], { record: {}, measure: "<measure>", ids: [] });
console.log(JSON.stringify(result));From the command line
$ mark statistics heldOutErrorAt --record <object> --measure <string> --ids <string[]>
As data, in a program
{
"$proc": ["statistics", "heldOutErrorAt"],
"input": { "record": {}, "measure": "<measure>", "ids": [] }
}Input
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
record | object | yes | ||
measure | string | yes | ||
ids | string[] | yes |
Output
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
n | number | yes | The number of held-out points. | |
folds | number | yes | The number of folds with this measure. | |
mae | number | yes | The mean absolute error of all the held-out points. | |
rmse | number | yes | The root mean square error of all the held-out points. | |
baselineMae | number | yes | The mean absolute error of the baseline. | |
skill | null | number | yes | The value `1 - mae / baselineMae`. The value 0 is no better than the mean. A baseline of 0 gives `null`. |
JSON Schemas
{
"input": {
"type": "object",
"properties": {
"record": {
"type": "object",
"properties": {
"models": {
"type": "array",
"items": {
"anyOf": [
{
"type": "object",
"properties": {
"kind": {
"type": "string",
"const": "ridge"
},
"lambda": {
"type": "number",
"description": "The penalty of the fit."
},
"inputs": {
"type": "array",
"items": {
"anyOf": [
{
"type": "object",
"properties": {
"kind": {
"type": "string",
"const": "level"
},
"levels": {
"type": "array",
"items": {
"type": "string"
}
},
"dimension": {
"type": "string"
},
"conditional": {
"type": "boolean",
"description": "When true, the dimension is conditional, so `null` is a good value. Each term of an absent dimension is 0."
}
},
"required": [
"kind",
"levels",
"dimension"
],
"additionalProperties": {}
},
{
"type": "object",
"properties": {
"kind": {
"type": "string",
"const": "number"
},
"center": {
"type": "number"
},
"spread": {
"type": "number"
},
"log": {
"type": "boolean"
},
"dimension": {
"type": "string"
},
"conditional": {
"type": "boolean",
"description": "When true, the dimension is conditional, so `null` is a good value. Each term of an absent dimension is 0."
}
},
"required": [
"kind",
"center",
"spread",
"dimension"
],
"additionalProperties": {}
},
{
"type": "object",
"properties": {
"kind": {
"type": "string",
"const": "rank"
},
"levels": {
"type": "array",
"items": {
"type": "string"
}
},
"center": {
"type": "number"
},
"spread": {
"type": "number"
},
"dimension": {
"type": "string"
},
"conditional": {
"type": "boolean",
"description": "When true, the dimension is conditional, so `null` is a good value. Each term of an absent dimension is 0."
}
},
"required": [
"kind",
"levels",
"center",
"spread",
"dimension"
],
"additionalProperties": {}
}
]
}
},
"intercept": {
"type": "number"
},
"terms": {
"type": "array",
"items": {
"type": "object",
"properties": {
"factors": {
"type": "array",
"items": {
"anyOf": [
{
"type": "object",
"properties": {
"dimension": {
"type": "string"
},
"level": {
"type": [
"string",
"number"
]
}
},
"required": [
"dimension",
"level"
],
"additionalProperties": {}
},
{
"type": "object",
"properties": {
"dimension": {
"type": "string"
},
"power": {
"type": "number"
}
},
"required": [
"dimension",
"power"
],
"additionalProperties": {}
}
]
}
},
"weight": {
"type": "number"
}
},
"required": [
"factors",
"weight"
],
"additionalProperties": {}
}
},
"measure": {
"type": "string",
"description": "The id of the measure of the model."
},
"scale": {
"type": "string",
"enum": [
"linear",
"log"
],
"description": "With `log`, the model and the held-out errors use the base-10 logarithm of the measure."
},
"floor": {
"type": "number",
"description": "With the scale `log`, the fit gave this value to each smaller measured value."
}
},
"required": [
"kind",
"lambda",
"inputs",
"intercept",
"terms",
"measure",
"scale"
],
"additionalProperties": {}
},
{
"type": "object",
"properties": {
"kind": {
"type": "string",
"const": "table"
},
"dimensions": {
"type": "array",
"items": {
"type": "string"
}
},
"conditional": {
"type": "array",
"items": {
"type": "string"
},
"description": "The ids of the dimensions of the table with a condition. Only these dimensions take `null`."
},
"cells": {
"type": "array",
"items": {
"type": "object",
"properties": {
"at": {
"type": "array",
"items": {
"type": [
"null",
"string",
"number"
]
},
"description": "The value of each dimension of the table, in the order of its `dimensions`. An absent dimension has `null`."
},
"value": {
"type": "number",
"description": "The mean of the measured values of the cell, on the scale of the model."
},
"n": {
"type": "number",
"description": "The number of points of the cell."
}
},
"required": [
"at",
"value",
"n"
],
"additionalProperties": {}
}
},
"fallback": {
"type": "number",
"description": "The value of a combination with no cell: the mean of all the fitted points, on the scale of the model."
},
"measure": {
"type": "string",
"description": "The id of the measure of the model."
},
"scale": {
"type": "string",
"enum": [
"linear",
"log"
],
"description": "With `log`, the model and the held-out errors use the base-10 logarithm of the measure."
},
"floor": {
"type": "number",
"description": "With the scale `log`, the fit gave this value to each smaller measured value."
}
},
"required": [
"kind",
"dimensions",
"cells",
"fallback",
"measure",
"scale"
],
"additionalProperties": {}
}
]
}
},
"folds": {
"type": "array",
"items": {
"type": "object",
"properties": {
"heldOut": {
"type": "array",
"items": {
"type": "string"
},
"description": "The ids of the held-out points."
},
"errors": {
"type": "object",
"properties": {},
"additionalProperties": {
"type": "object",
"properties": {
"n": {
"type": "number",
"description": "The number of held-out points with a value of the measure."
},
"mae": {
"type": "number",
"description": "The mean absolute error."
},
"rmse": {
"type": "number",
"description": "The root mean square error."
},
"baselineMae": {
"type": "number",
"description": "The mean absolute error of the mean of the training points, used as the prediction."
}
},
"required": [
"n",
"mae",
"rmse",
"baselineMae"
],
"additionalProperties": {}
},
"description": "The error of each measure. A measure with no held-out point or no training point has no entry."
},
"predictions": {
"type": "object",
"properties": {},
"additionalProperties": {
"type": "object",
"properties": {},
"additionalProperties": {
"type": "number"
}
},
"description": "The prediction of each held-out point with a value, on the scale of the model. The keys are the id of the measure, then the id of the point. The model of this fold gave them. Only the option `outOfFold` of `fitResponse` writes this field."
}
},
"required": [
"heldOut",
"errors"
],
"additionalProperties": {}
}
},
"schema": {
"type": "string",
"const": "response-records/1"
},
"name": {
"type": "string"
},
"dimensions": {
"type": "array",
"items": {
"anyOf": [
{
"type": "object",
"properties": {
"kind": {
"type": "string",
"const": "categorical"
},
"levels": {
"type": "array",
"items": {
"type": "string"
}
},
"id": {
"type": "string",
"description": "The key of the dimension in the values of a point."
},
"label": {
"type": "string",
"description": "The name that a view shows."
},
"unit": {
"type": "string",
"description": "The unit. An empty string means that the dimension has no unit."
},
"when": {
"type": "object",
"properties": {
"dimension": {
"type": "string",
"description": "The id of the parent: a categorical or ordinal dimension with no condition."
},
"levels": {
"type": "array",
"items": {
"type": [
"string",
"number"
]
}
}
},
"required": [
"dimension",
"levels"
],
"additionalProperties": {},
"description": "With this field, a point has a value only at the stated levels of the parent. Each other point has `null`."
}
},
"required": [
"kind",
"levels",
"id",
"label",
"unit"
],
"additionalProperties": {}
},
{
"type": "object",
"properties": {
"kind": {
"type": "string",
"const": "continuous"
},
"range": {
"type": "array",
"items": [
{
"type": "number"
},
{
"type": "number"
}
],
"additionalItems": {},
"minItems": 2,
"maxItems": 2,
"description": "The smallest and the largest value. The first is less than the second."
},
"log": {
"type": "boolean",
"description": "When true, a model and an axis use the base-10 logarithm of the value. All of the range is above 0."
},
"id": {
"type": "string",
"description": "The key of the dimension in the values of a point."
},
"label": {
"type": "string",
"description": "The name that a view shows."
},
"unit": {
"type": "string",
"description": "The unit. An empty string means that the dimension has no unit."
},
"when": {
"type": "object",
"properties": {
"dimension": {
"type": "string",
"description": "The id of the parent: a categorical or ordinal dimension with no condition."
},
"levels": {
"type": "array",
"items": {
"type": [
"string",
"number"
]
}
}
},
"required": [
"dimension",
"levels"
],
"additionalProperties": {},
"description": "With this field, a point has a value only at the stated levels of the parent. Each other point has `null`."
}
},
"required": [
"kind",
"range",
"id",
"label",
"unit"
],
"additionalProperties": {}
},
{
"type": "object",
"properties": {
"kind": {
"type": "string",
"const": "ordinal"
},
"levels": {
"anyOf": [
{
"type": "array",
"items": {
"type": "number"
}
},
{
"type": "array",
"items": {
"type": "string"
}
}
]
},
"log": {
"type": "boolean",
"description": "When true, a model uses the base-10 logarithm of the level. The levels are numbers above 0."
},
"id": {
"type": "string",
"description": "The key of the dimension in the values of a point."
},
"label": {
"type": "string",
"description": "The name that a view shows."
},
"unit": {
"type": "string",
"description": "The unit. An empty string means that the dimension has no unit."
},
"when": {
"type": "object",
"properties": {
"dimension": {
"type": "string",
"description": "The id of the parent: a categorical or ordinal dimension with no condition."
},
"levels": {
"type": "array",
"items": {
"type": [
"string",
"number"
]
}
}
},
"required": [
"dimension",
"levels"
],
"additionalProperties": {},
"description": "With this field, a point has a value only at the stated levels of the parent. Each other point has `null`."
}
},
"required": [
"kind",
"levels",
"id",
"label",
"unit"
],
"additionalProperties": {}
}
]
}
},
"measures": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "string",
"description": "The key of the measure in the measures of a point."
},
"label": {
"type": "string"
},
"unit": {
"type": "string",
"description": "The unit. An empty string means that the measure has no unit."
},
"direction": {
"type": "string",
"enum": [
"higher",
"lower",
"none"
],
"description": "The better direction of the value. The value `none` means that no direction is better."
},
"range": {
"type": "array",
"items": [
{
"type": "number"
},
{
"type": "number"
}
],
"additionalItems": {},
"minItems": 2,
"maxItems": 2,
"description": "The low and the high end of the possible values, for example `[0, 1]` for a share. Each measured value is in this range. A view clips its fitted values to it, and a fit does not use it."
}
},
"required": [
"id",
"label",
"unit",
"direction"
],
"additionalProperties": {}
}
},
"reasons": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "string",
"description": "The key of the reason in the field `absent` of a point."
},
"label": {
"type": "string",
"description": "The name that a view shows."
}
},
"required": [
"id",
"label"
],
"additionalProperties": {}
},
"description": "The reasons that a measure of a point can be absent. Each id in the field `absent` of a point is in this list."
},
"points": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"values": {
"type": "object",
"properties": {},
"additionalProperties": {
"type": [
"null",
"string",
"number"
]
},
"description": "The value of each dimension."
},
"measures": {
"type": "object",
"properties": {},
"additionalProperties": {
"type": [
"null",
"number"
]
},
"description": "The value of each measure. The value `null` means that the run did not give the measure at this point."
},
"group": {
"type": "string",
"description": "The points of one group stay on one side of each split, for example the repeats of one seed."
},
"absent": {
"type": "object",
"properties": {},
"additionalProperties": {
"type": "string"
},
"description": "The reason of a measure with `null`: a map from the id of the measure to the id of a declared reason."
}
},
"required": [
"id",
"values",
"measures"
],
"additionalProperties": {}
}
}
},
"required": [
"models",
"folds",
"schema",
"name",
"dimensions",
"measures",
"points"
],
"additionalProperties": {}
},
"measure": {
"type": "string"
},
"ids": {
"type": "array",
"items": {
"type": "string"
}
}
},
"required": [
"record",
"measure",
"ids"
],
"additionalProperties": false
},
"output": {
"type": "object",
"properties": {
"n": {
"type": "number",
"description": "The number of held-out points."
},
"folds": {
"type": "number",
"description": "The number of folds with this measure."
},
"mae": {
"type": "number",
"description": "The mean absolute error of all the held-out points."
},
"rmse": {
"type": "number",
"description": "The root mean square error of all the held-out points."
},
"baselineMae": {
"type": "number",
"description": "The mean absolute error of the baseline."
},
"skill": {
"description": "The value `1 - mae / baselineMae`. The value 0 is no better than the mean. A baseline of 0 gives `null`.",
"type": [
"null",
"number"
]
}
},
"required": [
"n",
"folds",
"mae",
"rmse",
"baselineMae",
"skill"
],
"additionalProperties": {}
}
}