Train Metric History#
- class rizemind.logging.train_metric_history.TrainMetricHistory(history: dict[str, list[float]] = {})[source]#
Bases:
BaseModelStandard class to log training metrics for clients.
The TrainMetricHistory class is used to log metrics that are gathered during the training phase. It is the standard class that is used in mods that perform logging. It has the capability to distinguish metrics for evaluation and training (during training phase).
- append(metrics: dict[str, bool | bytes | float | int | str], is_eval: bool)[source]#
Append a dictionary of metrics to the history.
Adds a suffix ‘_eval’ or ‘_train’ to the metric name based on the is_eval flag.
- Parameters:
metrics – A dictionary mapping metric names (str) to their scalar values.
is_eval – Indicates if the metrics are from an evaluation phase.
- classmethod deserialize(serialized_train_metric_history: str) TrainMetricHistory[source]#
Deserialize a JSON string into a TrainMetricHistory instance.
- Parameters:
serialized_train_metric_history – The JSON string representation of a TrainMetricHistory.
- Returns:
A new instance of the TrainMetricHistory class.
- items()[source]#
Return an iterable of the history’s items (key-value pairs).
The items is used as the equivalent for dict.items.
- Returns:
A view object displaying a list of the dictionary’s key-value tuple pairs.
- model_config: ClassVar[ConfigDict] = {}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_post_init(context: Any, /) None#
This function is meant to behave like a BaseModel method to initialise private attributes.
It takes context as an argument since that’s what pydantic-core passes when calling it.
- Parameters:
self – The BaseModel instance.
context – The context.
- serialize() dict[str, str][source]#
Serialize the TrainMetricHistory instance into its json representation.
The instance is converted to a JSON string and stored under a predefined key. This serialization ensures TrainMetricHistory compatibility with metrics as a [str, Scalar] type.
- Returns:
A dictionary containing the serialized TrainMetricHistory instance as a JSON string.