tracking_base
- class TrackingContext(name: str, experiment: Optional[sensai.tracking.tracking_base.TrackedExperiment])[source]
Bases:
abc.ABC
- __init__(name: str, experiment: Optional[sensai.tracking.tracking_base.TrackedExperiment])
- static from_optional_experiment(experiment: Optional[sensai.tracking.tracking_base.TrackedExperiment], model: Optional[sensai.vector_model.VectorModelBase] = None, name: Optional[str] = None, description: str = '')
- is_enabled()
- Returns
True if tracking is enabled, i.e. whether results can be saved via this context
- track_metrics(metrics: Dict[str, float], predicted_var_name: Optional[str] = None)
- Parameters
metrics – the metrics to be logged
predicted_var_name – the name of the predicted variable for the case where there is more than one. If it is provided, the variable name will be prepended to every metric name.
- abstract track_figure(name: str, fig: matplotlib.figure.Figure)
- Parameters
name – the name of the figure (not a filename, should not include file extension)
fig – the figure
- abstract track_text(name: str, content: str)
- Parameters
name – the name of the text (not a filename, should not include file extension)
content – the content (arbitrarily long text, e.g. a log)
- end()
- class DummyTrackingContext(name)[source]
Bases:
sensai.tracking.tracking_base.TrackingContext
A dummy tracking context which performs no actual tracking. It is useful to avoid having to write conditional tracking code for the case where there isn’t a tracked experiment.
- __init__(name)
- is_enabled()
- Returns
True if tracking is enabled, i.e. whether results can be saved via this context
- track_figure(name: str, fig: matplotlib.figure.Figure)
- Parameters
name – the name of the figure (not a filename, should not include file extension)
fig – the figure
- track_text(name: str, content: str)
- Parameters
name – the name of the text (not a filename, should not include file extension)
content – the content (arbitrarily long text, e.g. a log)
- class TrackedExperiment(context_prefix: str = '', additional_logging_values_dict=None)[source]
Bases:
Generic
[sensai.tracking.tracking_base.TContext
],abc.ABC
- __init__(context_prefix: str = '', additional_logging_values_dict=None)
Base class for tracking :param additional_logging_values_dict: additional values to be logged for each run
- track_values(values_dict: Dict[str, Any], add_values_dict: Dict[str, Any] = None)
- begin_context(name: str, description: str = '') sensai.tracking.tracking_base.TContext
Begins a context in which actual information will be tracked. The returned object is a context manager, which can be used in a with-statement.
- Parameters
name – the name of the context (e.g. model name)
description – a description (e.g. full model parameters/specification)
- Returns
the context, which can subsequently be used to track information
- begin_context_for_model(model: sensai.vector_model.VectorModelBase)
Begins a tracking context for the case where we want to track information about a model (wrapper around begin_context for convenience). The model name is used as the context name, and the model’s string representation is used as the description. The returned object is a context manager, which can be used in a with-statement.
- Parameters
model – the model
- Returns
the context, which can subsequently be used to track information
- end_context(instance: sensai.tracking.tracking_base.TContext)
- class TrackingMixin[source]
Bases:
abc.ABC
- set_tracked_experiment(tracked_experiment: Optional[sensai.tracking.tracking_base.TrackedExperiment])
- unset_tracked_experiment()
- property tracked_experiment: Optional[sensai.tracking.tracking_base.TrackedExperiment]
- begin_optional_tracking_context_for_model(model: sensai.vector_model.VectorModelBase, track: bool = True) sensai.tracking.tracking_base.TrackingContext
Begins a tracking context for the given model; the returned object is a context manager and therefore method should preferably be used in a with statement. This method can be called regardless of whether there actually is a tracked experiment (hence the term ‘optional’). If there is no tracked experiment, calling methods on the returned object has no effect. Furthermore, tracking can be disabled by passing track=False even if a tracked experiment is present.
- Parameters
model – the model for which to begin tracking
- Paraqm track
whether tracking shall be enabled; if False, force use of a dummy context which performs no actual tracking even if a tracked experiment is present
- Returns
a context manager that can be used to track results for the given model