Skip to content

Scales and measuring

A scale is a degree, not a probability. It describes ordered situations and the model returns a position along them. It is kept distinct from predicates on purpose: “how much does this disrupt work” is a different question from “is this disruptive”.

import { scale } from "jevlish";
import type { Ticket } from "./support.js";
// A degree, not a probability. Levels are ordered situations; the model
// returns a position along them. Two to ten levels.
export const disruption = scale<Ticket>("how much the reported problem disrupts the customer's work")
.from("Work continues normally; the problem affects appearance only")
.through("The task remains possible through a workaround")
.to("The task cannot be completed")
.named("disruption");
disruption.levels.length; // 3
disruption.top; // 2: scores run from 0 to top

.from(lowest) starts the levels, .through(level) adds intermediate ones (repeatable), and .to(highest) finishes. A scale needs at least two levels and supports at most ten. Each level is a description of a situation, not a number; the numbers are positions, 0 through scale.top.

A scale compiles to a Jev Score question with the levels as its criteria.

given(x).measure(scale) resolves to a Judgment<Measurement>.

import { given } from "jevlish";
import { ticket } from "./support.js";
import { disruption } from "./vocabulary.js";
const measurement = await given(ticket)
.seenAs((t) => ({ subject: t.subject, body: t.body }))
.measure(disruption);
if (measurement.status === "decided") {
const { score, normalized, level, levelDescription, confidence } = measurement.value;
score; // expected position, 0 .. disruption.top
normalized; // score / top
level; // the most likely level's index
levelDescription; // that level's text
confidence; // what the policy compared against policy.score.minConfidence
}

A decided measurement carries:

  • score: the expected position on the scale, a real number from 0 to top.
  • normalized: score / top, from 0 to 1.
  • level and levelDescription: the most likely level and its text.
  • confidence and probabilities: what the policy compared against policy.score.minConfidence, and the distribution behind it.

The judgment is uncertain when confidence misses the threshold.

from(items).rankedBy(scale, order) measures each accepted item and sorts by score. See Filtering and ranking.

A scale can be one of the questions in given(x).ask({ ... }), alongside conditions and Choices; it produces a Judgment<Measurement> under its key. See Asking several questions.