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.
| Type | Values | Notes |
|---|---|---|
numeric | any number | Aliases: float, number, continuous. min and max bound the values Kaimei makes up when it perturbs a row, and set the dashboard's sliders. A row you send is scored as it is, even outside them. |
integer | whole numbers | Alias: int. Anything else is refused with invalid_input. Perturbed values are rounded. |
binary | true / false, 0 / 1, yes / no | Alias: boolean. Anything else is refused with invalid_input. |
categorical | one of categories | Aliases: category, enum, string. Unknown values are rejected on strict endpoints. |
image | height × width × channels nested lists | Channels last, pixels in [0, 1] unless value_range says otherwise. Flat lists of the same length are accepted. |
text | a string, or a list of token ids | max_length: the token positions the model reads. longer: what is done with a text of more tokens, "cut" (the default) or "refuse". A string needs the model's tokenizer. See text and sequence models. |
tokens | a list of token ids | Alias: token_ids. max_length, and vocab_size when known; longer as for text. |
sequence | shape numbers, nested or flat | shape is [steps, channels]. Aliases: series, timeseries, time_series. |
tensor | shape numbers, nested or flat | Any shape of up to six axes. Aliases: array, vector, embedding, latent. |
audio | numbers, packed float32, or a WAV file as a data URL | samples, and sample_rate (16,000 when left out). Aliases: sound, waveform. See recordings. |
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), allow_missing (numeric and integer features of a model that handles missing values: an explicit null reaches the model as missing rather than taking the baseline; the Python client sets it when its check finds the model does), 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:
| Field | Applies to | Meaning |
|---|---|---|
labels | classification | Class names in output order. Binary models need exactly two; multiclass models must set them. |
positive_label | binary | The class whose probability is the model's score. Defaults to the second label. |
threshold | binary | Decision threshold on that probability. Default 0.5. |
name | all | What the output is called in reports (decision, demand_mw). |
unit | regression | Unit of the predicted value (MW, % / month). |
kind | all | probabilities (default), logits (a sigmoid or softmax is applied) or value; for a generation model, image, sequence or tensor. |
value_range, layout, shape | generation | The range of a generator's values, chw for a picture kept channels first, and the shape of what an endpoint or an agent returns. |
task is one of binary_classification, multiclass_classification or regression, one of the generative tasks (text_generation, sequence_to_sequence, generation or embedding), or one whose answer is labels, boxes, a mask or a group (multilabel_classification, object_detection, segmentation or clustering). For uploaded structures Kaimei infers the task, the features and the labels from the spec when you leave them out.
{
"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"
}
}