import numpy as np
CATEGORICAL_CHANNEL = "categorical"
NUMERICAL_CHANNEL = "numerical"
LABEL_CHANNEL = "label"
SPLIT_BINARY = "split_binary"
TRAIN_MAPPING = "train"
TEST_MAPPING = "test"
TYPE_SELECTOR = "type"
FEATURES_SELECTOR = "features"
FILES_SELECTOR = "files"
DTYPE_SELECTOR = "dtype"
CARDINALITY_SELECTOR = "cardinality"
def get_categorical_feature_type(size: int):
"""This function works both when max value and cardinality is passed.
Consistency by the user is required"""
types = (np.int8, np.int16, np.int32)
for numpy_type in types:
if size < np.iinfo(numpy_type).max:
return numpy_type
raise RuntimeError(f"Categorical feature of size {size} is too big for defined types")