← All procedures

statistics.parseResponseRecord

This function examines unknown data, for example the result of `JSON.parse`, against `response-records/1`. It gives `{ ok: true, record }`, with the same object as the record, or `{ ok: false, faults }`. Each fault has the path of the bad field and a message. The function does not throw. Data that the checks cannot read, for example an object with a loop, gives one fault.

CLI
Package
@procedures/statistics · README
Path
["statistics","parseResponseRecord"]
CLI
mark statistics parseResponseRecord --value <any>
As data
{"$proc":["statistics","parseResponseRecord"],"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","parseResponseRecord"], { value: "<value>" });
console.log(JSON.stringify(result));

From the command line

$ mark statistics parseResponseRecord --value <any>

As data, in a program

{
  "$proc": ["statistics", "parseResponseRecord"],
  "input": { "value": "<value>" }
}

Input

FieldTypeRequiredDefaultDescription
valueanyyes

Output

The schema does not list fields (object | object).

JSON Schemas
{
  "input": {
    "type": "object",
    "properties": {
      "value": {}
    },
    "required": [
      "value"
    ],
    "additionalProperties": false
  },
  "output": {
    "anyOf": [
      {
        "type": "object",
        "properties": {
          "ok": {
            "type": "boolean",
            "const": false
          },
          "faults": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "path": {
                  "type": "string",
                  "description": "The place of the fault, for example `points[3].values.size`. An empty string is the record itself."
                },
                "message": {
                  "type": "string",
                  "description": "What is wrong, and what the format needs."
                }
              },
              "required": [
                "path",
                "message"
              ],
              "additionalProperties": {}
            }
          }
        },
        "required": [
          "ok",
          "faults"
        ],
        "additionalProperties": {}
      },
      {
        "type": "object",
        "properties": {
          "ok": {
            "type": "boolean",
            "const": true
          },
          "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": {}
          }
        },
        "required": [
          "ok",
          "record"
        ],
        "additionalProperties": {}
      }
    ]
  }
}