saealib.CategoricalVariable#
- class saealib.CategoricalVariable(categories)[source]#
Bases:
VariableCategorical variable; stored internally as integer index.
Values are encoded as indices in
[0, n_categories - 1]and stored asfloat64in population arrays. Useencode()/decode()to convert between category values and their integer indices.- Parameters:
categories (list) – Ordered list of category values. Must be non-empty.
Examples
>>> v = CategoricalVariable(["red", "green", "blue"]) >>> v.encode("green") 1 >>> v.decode(1) 'green'
Methods
Return the category value for index. |
|
Return the integer index for category. |
|
Round x and clip to a valid category index. |
Method Details
- CategoricalVariable.decode(index)[source]#
Return the category value for index.
- Parameters:
index (int or float) – Index into
categories; rounded to nearest integer.- Return type:
category value