Skip to content

Main content

Onehot Single Category Index Tool

Encode one exact string category against an explicit ordered unique category vocabulary; unknown categories are rejected.

Loading tool…

Description

Return its zero-based index and one at that position with zeros elsewhere.

Weights express relative contributions. Dividing by their total creates weights that sum to one when the total is positive, but it does not establish that the original weighting scheme is suitable for the decision.

Return its zero-based index and one at that position with zeros elsewhere.

When to use this tool

Use Onehot Single Category Index when you need to normalize or inspect a supplied collection of nonnegative weights.

How to use the tool and how it works

  1. Enter categories, category. Use the units and conventions below.
  2. Run the tool. Correct any format, range, or cross-field input error before interpreting the output.
  3. Read index, oneHot. Use the output convention below.

Require unique category strings and category present in the list. Return its zero-based index and one at that position with zeros elsewhere.1

Input fieldMeaning and unitsAccepted input
categoriesCategoriesRequired. Array of text; maximum UTF-16 length 8192; maximum items 256.
categoryCategoryRequired. Text; maximum UTF-16 length 8192.
Output fieldInterpretationReturned shape
indexPosition under the zero-based or one-based convention stated above.Required. Safe integer.
oneHotOne HotRequired. Array of safe integer; maximum items 256.
json
{
  "input": {
    "categories": [
      "red",
      "green",
      "blue"
    ],
    "category": "green"
  },
  "output": {
    "index": 1,
    "oneHot": [
      0,
      1,
      0
    ]
  }
}

Limitations and assumptions

  • Unknown categories are rejected rather than given an all-zero encoding; category spelling and order are exact and supplied.
  • Inputs must satisfy both the field types and the cross-field conditions above. Invalid input causes an error; a successful false flag or documented placeholder is a different result.

Alternative or Complementary methods

Document how the weights were chosen and test the sensitivity of the complete weighted result.

References

  1. Calculation and input contract: normalize/onehot-single-category-index — tool.io

Similar or alternative tools