formulaic_contrasts.get_factor_storage_and_materializer

formulaic_contrasts.get_factor_storage_and_materializer#

formulaic_contrasts.get_factor_storage_and_materializer()#

Keeps track of categorical factors used in a model specification by generating a custom materializer.

This materializer reports back metadata upon materialization of the model matrix.

Return type:

tuple[dict[str, list[FactorMetadata]], dict[str, set[str]], type]

Returns:

  • A dictionary storing metadata for each factor processed by the custom materializer, named factor_storage.

  • A dictionary mapping variables to factor names, which works similarly to model_spec.variable_terms

    but maps to factors rather than terms, named variable_to_factors.

  • A materializer class tied to the specific instance of factor_storage.