## to_yaml()


Serialize a [FittedRecipe](FittedRecipe.md#mlfeatures.FittedRecipe) to a diffable YAML string.


Usage

``` python
to_yaml(recipe)
```


The same [to_dict](to_dict.md#mlfeatures.to_dict) payload as [to_json](to_json.md#mlfeatures.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](to_json.md#mlfeatures.to_json) when people will read or review the file; it needs the optional `pyyaml` package. Warns like [to_dict](to_dict.md#mlfeatures.to_dict) when the recipe names a class that [from_yaml](from_yaml.md#mlfeatures.from_yaml) refuses by default.


## Parameters


`recipe: FittedRecipe`  
The fitted recipe to serialize.


## Returns


`str`  
The YAML text.


## Raises


`ImportError`  
If the optional `pyyaml` package is not installed (`pip install mlfeatures[yaml]`).

`TypeError`  
As for [to_dict](to_dict.md#mlfeatures.to_dict).


## Examples


``` python
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'
