from_json(
text,
*,
trusted=(),
)
Takes the same trusted argument as from_dict and raises the same ValueError for a class outside the trusted packages. Text that is not valid JSON raises json.JSONDecodeError (a ValueError subclass).
Parameters
text: str
-
The JSON text produced by to_json.
trusted: Iterable[type] = ()
-
Classes whose top-level packages the payload may also name classes from; see from_dict. Defaults to none.
Examples
recipe = Recipe().add(StepNormalize(s.numeric_features()))
fitted = recipe.fit(credit)
restored = from_json(to_json(fitted))
restored.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 |