The feature schema

The feature schema

How a model declares its inputs and outputs, and how Kaimei uses that schema to validate, encode and report.

A model's features array declares its inputs. Kaimei uses it to validate rows, to encode categoricals and images into the numeric space the explainers work in, to decode them back for reports, and to fill in a baseline when a row omits a feature.

TypeValuesNotes
numericany numberAliases: float, number, continuous. min and max bound perturbations and counterfactual searches.
integerwhole numbersAlias: int. Perturbed values are rounded.
binarytrue / false, 0 / 1Alias: boolean.
categoricalone of categoriesAliases: category, enum, string. Unknown values are rejected on strict endpoints.
imageheight × width × channels nested listsChannels last, pixels in [0, 1] unless value_range says otherwise. Flat lists of the same length are accepted.

Optional fields on any feature: description, unit (shown in the dashboard and notebook cards), baseline (the value used when a row omits the feature, and the centre of perturbations), min, max, and for categoricals categories. Image features need height, width and channels, and may set value_range (for example [0, 255]) when callers send and the model reads 0 to 255 values; Kaimei holds pixels in [0, 1] internally and converts at the model boundary. Image features may also carry examples, labelled sample images that the dashboard offers as one-click inputs.

The outputs object describes what the model returns:

FieldApplies toMeaning
labelsclassificationClass names in output order. Binary models need exactly two; multiclass models must set them.
positive_labelbinaryThe class whose probability is the model's score. Defaults to the second label.
thresholdbinaryDecision threshold on that probability. Default 0.5.
nameallWhat the output is called in reports (decision, demand_mw).
unitregressionUnit of the predicted value (MW, % / month).
kindallprobabilities (default), logits (a sigmoid or softmax is applied) or value.

task is one of binary_classification, multiclass_classification or regression. For uploaded structures Kaimei infers the task, the features and the labels from the spec when you leave them out.

Feature schemafeatures and outputs in a model body
{
  "name": "Credit risk v3",
  "slug": "credit-risk-v3",
  "task": "binary_classification",
  "framework": "sklearn",
  "features": [
    {
      "name": "income",
      "type": "numeric",
      "unit": "USD/yr",
      "baseline": 65000,
      "min": 0,
      "description": "Annual gross income"
    },
    {
      "name": "credit_score",
      "type": "integer",
      "baseline": 690,
      "min": 300,
      "max": 850
    },
    {
      "name": "utilization",
      "type": "numeric",
      "baseline": 0.35,
      "min": 0,
      "max": 1.5
    },
    {
      "name": "num_delinquencies",
      "type": "integer",
      "baseline": 0,
      "min": 0,
      "max": 20
    },
    {
      "name": "home_ownership",
      "type": "categorical",
      "categories": ["rent", "mortgage", "own"],
      "baseline": "mortgage"
    },
    {
      "name": "photo",
      "type": "image",
      "height": 224,
      "width": 224,
      "channels": 3,
      "value_range": [0, 255],
      "description": "An image feature, for comparison"
    }
  ],
  "outputs": {
    "labels": ["approve", "decline"],
    "positive_label": "decline",
    "threshold": 0.5,
    "name": "decision"
  }
}