Model Client
class ModelClient()β
The submarine ModelsClient provides a high-level API for logging metrics / parameters and managing models.
ModelsClient(tracking_uri=None, registry_uri=None)->ModelsClient
β
Initialize a ModelsClient
instance.
Parameters
- tracking_uri: If run in Submarine, you do not need to specify it. Otherwise, specify the external tracking_uri.
- registry_uri: If run in Submarine, you do not need to specify it. Otherwise, specify the external registry_uri.
Returns
- ModelsClient instance
Example
from submarine import ModelsClient
modelClient = ModelsClient(tracking_uri="0.0.0.0:4000", registry_uri="0.0.0.0:5000")
ModelsClient.start()->[Active Run]
β
For details of Active Run
Start a new Mlflow run, and direct the logging of the artifacts and metadata to the Run named "worker_i" under Experiment "job_id". If in distributed training, worker and job id would be parsed from environment variable. If in local traning, worker and job id will be generated.
Returns
- Active Run
ModelsClient.log_param(key, value)->None
β
Log parameter under the current run.
Parameters
- key β Parameter name
- value β Parameter value
Example
from submarine import ModelsClient
modelClient = ModelsClient()
with modelClient.start() as run:
modelClient.log_param("learning_rate", 0.01)
ModelsClient.log_params(params)->None
β
Log a batch of params for the current run.
Parameters
- params β Dictionary of param_name: String -> value
Example
from submarine import ModelsClient
params = {"learning_rate": 0.01, "n_estimators": 10}
modelClient = ModelsClient()
with modelClient.start() as run:
modelClient.log_params(params)
ModelsClient.log_metric(self, key, value, step=None)->None
β
Log a metric under the current run.
Parameters
- key β Metric name (string).
- value β Metric value (float).
- step β Metric step (int). Defaults to zero if unspecified.
Example
from submarine import ModelsClient
modelClient = ModelsClient()
with modelClient.start() as run:
modelClient.log_metric("mse", 2500.00)
ModelsClient.log_metrics(self, metrics, step=None)->None
β
Log multiple metrics for the current run.
Parameters
- metrics β Dictionary of metric_name: String -> value: Float.
- step β A single integer step at which to log the specified Metrics. If unspecified, each metric is logged at step zero.
Example
from submarine import ModelsClient
metrics = {"mse": 2500.00, "rmse": 50.00}
modelClient = ModelsClient()
with modelClient.start() as run:
modelClient.log_metrics(metrics)
(Beta) ModelsClient.save_model(self, model_type, model, artifact_path, registered_model_name=None)
β
Save model to model registry.
(Beta) ModelsClient.load_model(self, name, version)->mlflow.pyfunc.PyFuncModel
β
Load a model from model registry.
(Beta) ModelsClient.update_model(self, name, new_name)->None
β
Update a model by new name.
(Beta) ModelsClient.delete_model(self, name, version)->None
β
Delete a model in model registry.