The same to_dict payload as to_json, written as YAML with the keys in their stable order and a block layout that diffs cleanly in review, so the two formats round-trip identically. Choose it over to_json when people will read or review the file; it needs the optional pyyaml package. Warns like to_dict when the recipe names a class that from_yaml refuses by default.
Parameters
recipe: FittedRecipe
-
The fitted recipe to serialize.
Raises
ImportError
-
If the optional pyyaml package is not installed (pip install mlfeatures[yaml]).
TypeError
-
As for to_dict.
Examples
recipe = Recipe().add(StepNormalize(s.numeric_features()))
fitted = recipe.fit(credit)
text = to_yaml(fitted)
text[:200]
'mlfeatures_version: 0.1.1.dev1+g5e6dda29d\nformat_version: 1\nroles:\n Status:\n - feature\n Seniority:\n - feature\n Home:\n - feature\n Time:\n - feature\n Age:\n - feature\n Marital:\n - feature\n Re'