statistics.surfaceResponse
This function gives the view of `sliceResponse` over two dimensions. The fields `x` and `y` are the two axes, and `cells` has one row for each value of `y`. The rules of the held values, of the matching points and of the band are the rules of `sliceResponse`. The function also throws a RangeError when the two varied dimensions are one dimension. It throws when a conditional dimension varies with its parent, and when two varied dimensions need no common level.
CLI- Package
- @procedures/statistics · README
- Path
["statistics","surfaceResponse"]- CLI
mark statistics surfaceResponse --record <object> --measure <string> --options <object>- As data
{"$proc":["statistics","surfaceResponse"],"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","surfaceResponse"], { record: {}, measure: "<measure>", options: {} });
console.log(JSON.stringify(result));From the command line
$ mark statistics surfaceResponse --record <object> --measure <string> --options <object>
As data, in a program
{
"$proc": ["statistics", "surfaceResponse"],
"input": { "record": {}, "measure": "<measure>", "options": {} }
}Input
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
record | object | yes | ||
measure | string | yes | ||
options | object | yes |
Output
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
measure | string | yes | ||
vary | any[] | yes | ||
held | object | yes | The value of each other dimension. | |
x | string | number[] | yes | ||
y | string | number[] | yes | ||
cells | object[][] | yes | One row for each value of `y`. Each row has one cell for each value of `x`. | |
points | object[] | yes | ||
absent | object[] | yes | The points that match the held values and have no value of the measure, each with its reason. | |
error | object | yes | ||
clipped | number | yes | The number of places of `cells` with the field `clipped`. |
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"
},
"options": {
"type": "object",
"properties": {
"vary": {
"type": "array",
"items": [
{
"type": "string"
},
{
"type": "string"
}
],
"additionalItems": {},
"minItems": 2,
"maxItems": 2,
"description": "The ids of the two dimensions of the surface: first the x axis, then the y axis."
},
"hold": {
"type": "object",
"properties": {},
"additionalProperties": {
"type": [
"null",
"string",
"number"
]
},
"description": "The value of each held dimension. Each other dimension takes its usual value, as `sliceResponse` tells."
},
"steps": {
"type": "number",
"description": "The number of values on a continuous axis, 2 or more. The default is 33."
},
"tolerance": {
"type": "number",
"description": "The share of the range of a held number dimension in which a point matches. A log dimension uses the log scale. The default is 0: only an equal value matches."
},
"width": {
"type": "number",
"description": "The half width of the band, as a multiple of the held-out root mean square error. The default is 1."
}
},
"required": [
"vary"
],
"additionalProperties": {}
}
},
"required": [
"record",
"measure",
"options"
],
"additionalProperties": false
},
"output": {
"type": "object",
"properties": {
"measure": {
"type": "string"
},
"vary": {
"type": "array",
"items": [
{
"type": "string"
},
{
"type": "string"
}
],
"additionalItems": {},
"minItems": 2,
"maxItems": 2
},
"held": {
"type": "object",
"properties": {},
"additionalProperties": {
"type": [
"null",
"string",
"number"
]
},
"description": "The value of each other dimension."
},
"x": {
"type": "array",
"items": {
"type": [
"string",
"number"
]
}
},
"y": {
"type": "array",
"items": {
"type": [
"string",
"number"
]
}
},
"cells": {
"type": "array",
"items": {
"type": "array",
"items": {
"type": "object",
"properties": {
"value": {
"type": "number"
},
"low": {
"type": "number"
},
"high": {
"type": "number"
},
"nearest": {
"type": "number",
"description": "The distance from this place to the nearest measured point with a value of the measure, from 0 to 1. The value 0 means that a point was measured here. A number or rank dimension counts as its share of the axis. A different categorical level counts 1, and an absent value against a present value counts 1. The distance is the largest count over the dimensions."
},
"clipped": {
"type": "boolean",
"const": true,
"description": "This field is true when the measure has a `range` and the view moved `value`, `low` or `high` into it."
}
},
"required": [
"value",
"low",
"high",
"nearest"
],
"additionalProperties": {}
}
},
"description": "One row for each value of `y`. Each row has one cell for each value of `x`."
},
"points": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"at": {
"type": "array",
"items": [
{
"type": [
"string",
"number"
]
},
{
"type": [
"string",
"number"
]
}
],
"additionalItems": {},
"minItems": 2,
"maxItems": 2,
"description": "The values of the two varied dimensions."
},
"value": {
"type": "number"
},
"group": {
"type": "string"
}
},
"required": [
"id",
"at",
"value"
],
"additionalProperties": {}
}
},
"absent": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"at": {
"type": "array",
"items": [
{
"type": [
"string",
"number"
]
},
{
"type": [
"string",
"number"
]
}
],
"additionalItems": {},
"minItems": 2,
"maxItems": 2,
"description": "The values of the two varied dimensions."
},
"reason": {
"description": "The id of the declared reason. The value `null` means that the point states no reason.",
"type": [
"null",
"string"
]
},
"group": {
"type": "string"
}
},
"required": [
"id",
"at",
"reason"
],
"additionalProperties": {}
},
"description": "The points that match the held values and have no value of the measure, each with its reason."
},
"error": {
"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": {}
},
"clipped": {
"type": "number",
"description": "The number of places of `cells` with the field `clipped`."
}
},
"required": [
"measure",
"vary",
"held",
"x",
"y",
"cells",
"points",
"absent",
"error",
"clipped"
],
"additionalProperties": {}
}
}