roles = Roles(
{"price": {"target"}, "age": {"feature"}, "city": {"feature"}}
)
roles.columns_with_role("feature"), roles.of("price")(['age', 'city'], {'target'})
Column → set of role names.
Usage
Every column carries zero or more roles stored as a set[str]. The standard roles are "target", "feature", and "case_weights"; users may register arbitrary custom roles. A column may hold several roles at once, but nonsensical combinations are rejected at assignment time: "target" and "feature" cannot share a column.
A column that carries no role is not selected by role selectors. Note that when a recipe declares no "feature" columns at all, fitting assigns the role to every column that is not a target or a case-weights column, custom roles included; declare features explicitly to keep, say, an ID column out of them.
Construct from a column → roles mapping, then query it: