Each step decides what it can drop: a step that keeps something only for inspection after fitting, or only because fitting needed it, returns a lighter version of itself that transforms identically. A step that has nothing to drop is kept as is, shared with recipe rather than copied, and recipe itself is never modified. The roles, schema, and lineage are kept, so the minimized recipe still validates new data at the boundary and reports its lineage.
Call it before to_dict, to_json, or to_yaml when the recipe is going to be shipped with a model, so the saved file carries only what scoring needs; the writers save the recipe as it is and do not minimize it. No shipped step currently holds anything to drop, so today the result is an equivalent recipe.
Parameters
recipe: FittedRecipe
-
The fitted recipe to minimize.
Returns
FittedRecipe
-
A new recipe with each step minimized.
Examples
recipe = Recipe().add(StepNormalize(s.numeric_features()))
fitted = recipe.fit(credit)
small = minimize(fitted)
small.transform(credit).head()
shape: (5, 14)| Status | Seniority | Home | Time | Age | Marital | Records | Job | Expenses | Income | Assets | Debt | Amount | Price |
|---|
| str | f64 | str | f64 | f64 | str | str | str | f64 | f64 | f64 | f64 | f64 | f64 |
| "good" | 0.104473 | "rent" | 0.911743 | -0.630317 | "married" | "no" | "freelance" | 0.887353 | -0.157881 | -0.541693 | -0.313105 | -0.501373 | -0.997081 |
| "good" | 1.086074 | "rent" | 0.911743 | 1.909999 | "widow" | "no" | "fixed" | -0.404875 | -0.133084 | -0.541693 | -0.313105 | -0.065705 | 0.344189 |
| "bad" | 0.227173 | "owner" | -0.738506 | 0.821292 | "married" | "yes" | "freelance" | 1.766069 | 0.722397 | -0.220497 | -0.313105 | 2.112637 | 2.536142 |
| "good" | -0.999828 | "rent" | 0.911743 | -1.17467 | "single" | "no" | "fixed" | 0.370462 | 0.499228 | -0.274029 | -0.313105 | -0.283539 | -0.205864 |
| "good" | -0.999828 | "rent" | -0.738506 | -0.993219 | "single" | "no" | "fixed" | -0.508253 | -0.430643 | -0.541693 | -0.313105 | -1.56876 | -0.891365 |