statistics.fitResponse
This function fits each measure of `data`, and it gives a record with the models and the folds.
CLI- Package
- @procedures/statistics · README
- Path
["statistics","fitResponse"]- CLI
mark statistics fitResponse --data <object>- As data
{"$proc":["statistics","fitResponse"],"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","fitResponse"], { data: {} });
console.log(JSON.stringify(result));From the command line
$ mark statistics fitResponse --data <object>
As data, in a program
{ "$proc": ["statistics", "fitResponse"], "input": { "data": {} } }Input
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
data | object | yes | ||
options | object | no |
Output
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
models | object | object[] | yes | ||
folds | object[] | yes | ||
schema | string | yes | ||
name | string | yes | ||
dimensions | object | object | object[] | yes | ||
measures | object[] | yes | ||
reasons | object[] | no | 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 | object[] | yes |
JSON Schemas
{
"input": {
"type": "object",
"properties": {
"data": {
"type": "object",
"properties": {
"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": [
"schema",
"name",
"dimensions",
"measures",
"points"
],
"additionalProperties": {}
},
"options": {
"type": "object",
"properties": {
"folds": {
"type": "number",
"description": "The number of folds, 3 or more. With fewer groups, each group is one fold. The default is 5."
},
"seed": {
"description": "The seed of the split. The default is 1.",
"type": [
"string",
"number"
]
},
"model": {
"type": "string",
"enum": [
"auto",
"ridge",
"table"
],
"description": "The kind of model. The default `auto` gives a table when each dimension is categorical, and a ridge fit otherwise."
},
"degree": {
"type": "number",
"description": "The largest total power of a term of a ridge fit, from 1 to 8. The default is 2."
},
"interactions": {
"anyOf": [
{
"type": "boolean"
},
{
"type": "string",
"const": "seen"
}
],
"description": "When true, a ridge fit also has the products of two dimensions, up to `degree`. The default is true. The value false also removes the products of a conditional dimension with the levels of its parent. Thus this option is the way out of the limit `RESPONSE_MAX_TERMS`."
},
"terms": {
"type": "array",
"items": {
"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": {}
}
]
}
},
"description": "The stated terms of a ridge fit, in place of `degree` and `interactions`."
},
"lambdas": {
"type": "array",
"items": {
"type": "number"
},
"description": "The penalties that a ridge fit chooses from, each above 0. The default is `RESPONSE_LAMBDAS`."
},
"log": {
"type": "array",
"items": {
"type": "string"
},
"description": "The ids of the measures to fit on a log scale."
},
"logFloor": {
"type": "number",
"description": "On a log scale, each smaller value takes this value. With no floor, a value of 0 or less is an error."
},
"outOfFold": {
"type": "boolean",
"description": "When true, each fold stores the prediction of each held-out point with a value. Then `heldOutErrorAt` gives the error of a chosen set of points. The default is false, and the record then has no field `predictions`."
}
},
"additionalProperties": {}
}
},
"required": [
"data"
],
"additionalProperties": false
},
"output": {
"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": {}
}
}