The model experiments Python API provides a set of methods for writing metrics and hyperparameters to experiments. This page contains information on available functions and classes in the palantir_models.experiments
package.
palantir_models.experiments.Experiment
A class for tracking model training experiments. An experiment can be created from any ModelOutput
class.
Copied!1
model_output.create_experiment(name="experiment-name")
Function | Description |
---|---|
log_param(key, value) | Log a single parameter to an experiment. |
log_params(parameter_map) | Log a set of parameters to an experiment. |
log_metric(name, value, step) | Log a metric value to an experiment under the given series. |
log_metrics(metric_values, step) | Log a set of metric values to an experiment under the given series. |
palantir_models.experiments.ErrorHandlerType
An enum for controlling how errors are handled when running experiment code. This specifically governs errors caused by non-user code such as network errors when writing metrics, or experiment size overflows.
Variant | Description |
---|---|
ErrorHandlerType.FAIL | Fail on any error. Will re-raise the error back to the caller. |
ErrorHandlerType.WARN | Warn on the first error, then suppress the rest. |
ErrorHandlerType.SUPPRESS | Do not log anything. |
The desired error handler type can be passed to ModelOutput.create_experiment
when creating an experiment as shown below:
Copied!1 2
from palantir_models.experiments import ErrorHandlerType model_output.create_experiment(name="mnist-experiment", error_handler_type=ErrorHandlerType.WARN)
Experiment.log_param
palantir_models.experiments.Experiment.log_param(key: str, value: Union[bool, date, datetime, float, int, str])
value
to the given key
.Copied!1
experiment.log_param(key="learning_rate", value=1e-3)
key
: str
value
: Union[bool, date, datetime, float, int, str]
Experiment.log_params
palantir_models.experiments.Experiment.log_params(parameter_map: Dict[str, Union[bool, date, datetime, float, int, str]])
log_param
.Copied!1 2 3 4
experiment.log_params(parameter_map={ "learning_rate": 1e-3, "model_type": "CNN" })
parameter_map
: Dict[str, Union[bool, date, datetime, float, int, str]]
Experiment.log_metric
palantir_models.experiments.Experiment.log_metric(metric_name: str, metric_value: float, step: Optional[int] = None)
step
is provided, an attempt to log at that step will be made. If the step has already been logged to, an error will be raised.step
is not provided, the current step of the series will be auto-incremented by 1.Copied!1 2
experiment.log_metric(metric_name="train/loss", metric_value=1.5) experiment.log_metric(metric_name="train/loss", metric_value=0.9) # will auto-increment the step
metric_name
: str
metric_value
: float
step
: Optional[int]
Experiment.log_metrics
palantir_models.experiments.Experiment.log_metrics(values: Dict[str, float], step: Optional[int] = None)
log_metric
.step
is provided, an attempt to log at that step will be made. If the step has already been logged to on any series, an error will be raised.step
is not provided, the current step of the all the series will be independently auto-incremented by 1.Copied!1 2 3 4
experiment.log_metrics(values={ "train/loss": 1.5, "train/acc", 0.7 })
values
: Dict[str, float]
step
: Optional[int]