I/O
glide.io
to_json
to_json(result)
Convert a MeanInferenceResult to a JSON string representation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result
|
MeanInferenceResult
|
The inference result object containing mean, standard deviation, and confidence interval. |
required |
Returns:
| Type | Description |
|---|---|
str
|
A JSON-formatted string representation of the inference result with 2-space indentation. |
Examples:
>>> from glide.io import to_json
>>> from glide.mean_inference_results import MeanInferenceResult
>>> from glide.confidence_intervals import CLTConfidenceInterval
>>> confidence_interval = CLTConfidenceInterval(mean=0, std=1)
>>> inference_result = MeanInferenceResult(confidence_interval=confidence_interval, metric_name="metric", estimator_name="none")
>>> print(to_json(inference_result))
{
"confidence_interval": {
"confidence_level": 0.95,
"lower_bound": -1.95...,
"upper_bound": 1.95...,
"width": 3.91...
},
"metric_name": "metric",
"estimator_name": "none",
"mean": 0,
"std": 1
}
Source code in glide/io/export.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | |