label_decode
Builtin index · Statistics & ML
label_decode(codes, classes)
Input: codes, classes · Output: no output
What it is
The inverse of label_encode: the classes entry at each 0-based code, a Vec when classes is numeric and a list when it holds strings. Use it to turn a model's integer predictions back into the original labels. Errors: a code that is not a whole number or lies outside 0 .. K-1.
Overloads
One call shape — this function is not overloaded.
| Code | Input | Output | Description |
label_decode(codes, classes) | codes —not documented yetclasses Vec or stringThe inverse of label_encode: the classes entry at each 0-based code, a Vec when classes is numeric and a list when it holds strings. | not documented yet | Use it to turn a model's integer predictions back into the original labels. Errors: a code that is not a whole number or lies outside 0 .. K-1. |
Examples
From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.
colors = ("red", "green", "blue", "green", "red", "blue", "green", "red")
e = label_encode(colors)
print("classes: {e.classes}")
print("codes: {e.codes}")
print("back: {label_decode(e.codes, e.classes)}")
oh = one_hot(colors)
print("one_hot is {rows(oh.matrix)} x {cols(oh.matrix)}, columns = {oh.classes}")
output
classes: ("blue", "green", "red")
codes: [2, 1, 0, 1, 2, 0, 1, 2]
back: ("red", "green", "blue", "green", "red", "blue", "green", "red")
one_hot is 8 x 3, columns = ("blue", "green", "red")from statistics-ml