All columns name descends from, transitively.
Walks parent_cols through archived nodes too, so a column traces back through removed intermediates (e.g. a polynomial term back to a distance column back to the numeric features it was computed from). The result is an unordered set; wrap it in sorted() for stable display.
Parameters
name: str
-
A column that is live or has been removed.
Returns
set of str
-
Every column
name descends from; empty for an original column.
Raises
KeyError
-
If no column called
name ever existed.
Examples
ancestors walks the whole chain, even through columns that later steps removed. Here StepClassDistance builds distance_good from the numeric features, then StepPolynomial consumes distance_good and expands it into polynomial terms:
recipe = (
Recipe(target="Status")
.add(StepImputeMean(s.numeric_features()))
.add(StepClassDistance(s.numeric_features(), target="Status"))
.add(StepPolynomial(s.col("distance_good"), degree=2))
)
fitted = recipe.fit(credit)
lineage = fitted.lineage
lineage.columns
['Status',
'Home',
'Marital',
'Records',
'Job',
'distance_bad',
'distance_good_1',
'distance_good_2']
A polynomial term traces back through the now-removed distance_good to the original features it was built from:
sorted(lineage.ancestors("distance_good_1"))
['Age',
'Amount',
'Assets',
'Debt',
'Expenses',
'Income',
'Price',
'Seniority',
'Time',
'distance_good']