← All procedures

statistics.selectRatingModel

The choice of a rating model by the log-loss on held-out picks. Each model learns from the first picks of the log and forecasts the last `holdout` part. All models use the tie parameter of the Bradley-Terry fit of the first picks. Thus the strengths are the only difference. Two equal scores keep the order of `models`. Each pick has the weight 1.

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

From the command line

$ mark statistics selectRatingModel --items <number> --comparisons <object[]>

As data, in a program

{
  "$proc": ["statistics", "selectRatingModel"],
  "input": { "items": 1, "comparisons": [] }
}

Input

FieldTypeRequiredDefaultDescription
itemsnumberyes
comparisonsobject[]yes
optionsobjectno

Output

FieldTypeRequiredDefaultDescription
model"bradley-terry" | "elo" | "glicko2"yesThe model with the lowest log-loss, or `"bradley-terry"` when the log has too few picks for a test.
scoresobject[]yesThe score of each model, from the best to the worst. It is empty when the log has too few picks for a test.
trainednumberyesThe number of picks that the models learn from.
testednumberyesThe number of held-out picks.
JSON Schemas
{
  "input": {
    "type": "object",
    "properties": {
      "items": {
        "type": "number"
      },
      "comparisons": {
        "type": "array",
        "items": {
          "type": "object",
          "properties": {
            "a": {
              "type": "number"
            },
            "b": {
              "type": "number"
            },
            "outcome": {
              "type": "string",
              "enum": [
                "a",
                "b",
                "tie"
              ]
            },
            "weight": {
              "type": "number",
              "description": "The weight of the comparison. The default is 1. A weight of 2 counts as two equal comparisons."
            }
          },
          "required": [
            "a",
            "b",
            "outcome"
          ],
          "additionalProperties": {}
        }
      },
      "options": {
        "type": "object",
        "properties": {
          "holdout": {
            "type": "number",
            "description": "The part of the picks, at the end of the log, that the test uses. It is above 0 and below 1. The default is 0.2."
          },
          "minimum": {
            "type": "number",
            "description": "The fewest picks for a test. With fewer picks, the choice is `\"bradley-terry\"`. The default is 30."
          },
          "models": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "bradley-terry",
                "elo",
                "glicko2"
              ]
            },
            "description": "The models to compare. The default is all three, in the order `\"bradley-terry\"`, `\"elo\"` and `\"glicko2\"`."
          },
          "bradleyTerry": {
            "type": "object",
            "properties": {
              "priorMean": {
                "type": "number",
                "description": "The mean of the prior of each log-strength. The default is 0."
              },
              "priorSd": {
                "type": "number",
                "description": "The standard deviation of the prior of each log-strength. The default is 1. A smaller value pulls the strengths together."
              },
              "ties": {
                "type": "string",
                "enum": [
                  "davidson",
                  "half"
                ],
                "description": "The model of a tie. With `\"davidson\"` (the default), the fit also gives a tie parameter. With `\"half\"`, a tie counts as half a win and half a loss of each item, and the tie parameter is 0."
              },
              "tiePriorSd": {
                "type": "number",
                "description": "The standard deviation of the normal prior of the log of the tie parameter, with mean 0. The default is 10. The prior is weak. It keeps the parameter finite when each comparison is a tie."
              },
              "maxIterations": {
                "type": "number",
                "description": "The largest number of Newton steps. The default is 100."
              },
              "tolerance": {
                "type": "number",
                "description": "The fit stops when the full Newton step moves no parameter more than this value. The default is 1e-10."
              }
            },
            "additionalProperties": {},
            "description": "The options of the Bradley-Terry fit. They go to `bradleyTerry` and to `bradleyTerrySparse`."
          },
          "denseLimit": {
            "type": "number",
            "description": "The largest number of items for the dense fit `bradleyTerry`. A larger log uses `bradleyTerrySparse`. The default is 200."
          },
          "elo": {
            "type": "object",
            "properties": {
              "start": {
                "type": "number",
                "description": "The rating of each item before its first pick. The default is 1500."
              },
              "k": {
                "type": "number",
                "description": "The largest change of a rating after one result (the K factor). The default is 32."
              },
              "center": {
                "type": "number",
                "description": "The rating of the log-strength 0. The default is 1500. Elo uses only differences, so it does not read it."
              },
              "scale": {
                "type": "number",
                "description": "The number of points that gives odds of `base` to 1. The default is 400."
              },
              "base": {
                "type": "number",
                "description": "The base of the odds. The default is 10."
              }
            },
            "additionalProperties": {},
            "description": "The options of the Elo replay. Its scale also converts the ratings to log-strengths."
          },
          "glicko2": {
            "type": "object",
            "properties": {
              "start": {
                "type": "object",
                "properties": {
                  "rating": {
                    "type": "number"
                  },
                  "rd": {
                    "type": "number",
                    "description": "The rating deviation, in rating points. It is above 0."
                  },
                  "volatility": {
                    "type": "number",
                    "description": "The volatility: the expected size of a change of the true strength in one rating period. It is above 0."
                  }
                },
                "required": [
                  "rating",
                  "rd",
                  "volatility"
                ],
                "additionalProperties": {},
                "description": "The rating of each item before its first pick. The default is the rating 1500, the RD 350 and the volatility 0.06."
              },
              "tau": {
                "type": "number",
                "description": "The constraint on the change of the volatility over time (tau). The default is 0.5. Glickman uses 0.3 to 1.2."
              },
              "tolerance": {
                "type": "number",
                "description": "The tolerance of the iteration for the new volatility (epsilon). The default is 0.000001, as in the paper."
              }
            },
            "additionalProperties": {},
            "description": "The options of the Glicko-2 replay."
          }
        },
        "additionalProperties": {}
      }
    },
    "required": [
      "items",
      "comparisons"
    ],
    "additionalProperties": false
  },
  "output": {
    "type": "object",
    "properties": {
      "model": {
        "type": "string",
        "enum": [
          "bradley-terry",
          "elo",
          "glicko2"
        ],
        "description": "The model with the lowest log-loss, or `\"bradley-terry\"` when the log has too few picks for a test."
      },
      "scores": {
        "type": "array",
        "items": {
          "type": "object",
          "properties": {
            "model": {
              "type": "string",
              "enum": [
                "bradley-terry",
                "elo",
                "glicko2"
              ]
            },
            "logLoss": {
              "type": "number",
              "description": "The mean of `-ln(p)` over the held-out picks, with `p` the forecast of the outcome of the pick. Lower is better."
            }
          },
          "required": [
            "model",
            "logLoss"
          ],
          "additionalProperties": {}
        },
        "description": "The score of each model, from the best to the worst. It is empty when the log has too few picks for a test."
      },
      "trained": {
        "type": "number",
        "description": "The number of picks that the models learn from."
      },
      "tested": {
        "type": "number",
        "description": "The number of held-out picks."
      }
    },
    "required": [
      "model",
      "scores",
      "trained",
      "tested"
    ],
    "additionalProperties": {}
  }
}