humancompatible.detect.data_handler.features.Categorical module

class humancompatible.detect.data_handler.features.Categorical.Categorical(training_vals: ndarray | Series, value_names: list[int | str] | None = None, map_to: list[float] | None = None, ordering: list[int | str] | None = None, name: str | None = None, monotone: Monotonicity = Monotonicity.NONE, modifiable: bool = True)[source]

Bases: Feature

allowed_change(pre_val: int | str, post_val: int | str, encoded=True) bool[source]

Checks whether value change from pre_val to post_val is allowed by mutability and similar properties

decode(vals: ndarray[float64], denormalize: bool = True, return_series: bool = True, discretize: bool = False) ndarray | Series[source]

Decodes the vals into the original form

encode(vals: ndarray | Series, *args, **kwargs)

Encodes the vals

encoding_width(one_hot: bool) int[source]

Returns the width of the encoded values, i.e., the size in teh second dimension (axis 1)

greater_than(num_val: int) list[int][source]
lower_than(num_val: int) list[int][source]
property n_categorical_vals
property numeric_vals
property orig_vals
property value_mapping