Skip to content

glassbox.inspector.auto_typer

Automatic feature type inference (Numerical, Nominal, Ordinal, Boolean).


AutoTyper

Infers logical data types for dataset columns.

infer_types

infer_types(data)

Infer feature types for all columns in the dataset.

Parameters:

Name Type Description Default
data Dataset

The dataset to analyze.

required

Returns:

Type Description
Dict

Mapping from column names to their inferred FeatureType.

Source code in glassbox/inspector/auto_typer.py
def infer_types(self, data: Dataset) -> Dict[str, FeatureType]:
    """
    Infer feature types for all columns in the dataset.

    Parameters
    ----------
    data : Dataset
        The dataset to analyze.

    Returns
    -------
    Dict
        Mapping from column names to their inferred FeatureType.
    """
    results = {}
    for col_name in data.columns:
        col_data = data.get_columns(col_name).data[:, 0]

        if self._is_boolean(col_data):
            results[col_name] = FeatureType.BOOLEAN
        elif self._is_numeric(col_data):
            if self._is_ordinal(col_data):
                results[col_name] = FeatureType.ORDINAL
            else:
                results[col_name] = FeatureType.NUMERICAL
        else:
            results[col_name] = FeatureType.NOMINAL
    return results