Deployment

class datarobot.models.Deployment

A deployment created from a DataRobot model.

Variables:
  • id (str) – the id of the deployment

  • label (str) – the label of the deployment

  • description (str) – the description of the deployment

  • status (str) – (New in version v2.29) deployment status

  • default_prediction_server (dict) –

    Information about the default prediction server for the deployment. Accepts the following values

    • id str Prediction server ID.

    • url Optional[str] Prediction server URL.

    • datarobot-key str Corresponds the to the PredictionServer “snake_cased” datarobot_key parameter that allows you to verify and access the prediction server.

  • importance (Optional[str]) – deployment importance

  • model (dict) – information on the model of the deployment

  • model_package (dict) – (New in version v3.4) information on the model package of the deployment

  • prediction_usage (dict) – information on the prediction usage of the deployment

  • permissions (list) – (New in version v2.18) user’s permissions on the deployment

  • service_health (dict) – information on the service health of the deployment

  • model_health (dict) – information on the model health of the deployment

  • accuracy_health (dict) – information on the accuracy health of the deployment

  • fairness_health (dict) – information on the fairness health of a deployment

  • governance (dict) – information on approval and change requests of a deployment

  • owners (dict) – information on the owners of a deployment

  • prediction_environment (dict) – information on the prediction environment of a deployment

classmethod create_from_learning_model(model_id, label, description=None, default_prediction_server_id=None, importance=None, prediction_threshold=None, status=None, max_wait=600)

Create a deployment from a DataRobot model.

Added in version v2.17.

Parameters:
  • model_id (str) – id of the DataRobot model to deploy

  • label (str) – a human-readable label of the deployment

  • description (Optional[str]) – a human-readable description of the deployment

  • default_prediction_server_id (Optional[str]) – an identifier of a prediction server to be used as the default prediction server

  • importance (Optional[str]) – deployment importance

  • prediction_threshold (Optional[float]) – threshold used for binary classification in predictions

  • status (Optional[str]) – deployment status

  • max_wait (Optional[int]) – Seconds to wait for successful resolution of a deployment creation job. Deployment supports making predictions only after a deployment creating job has successfully finished.

Returns:

deployment – The created deployment

Return type:

Deployment

Examples

from datarobot import Project, Deployment
project = Project.get('5506fcd38bd88f5953219da0')
model = project.get_models()[0]
deployment = Deployment.create_from_learning_model(model.id, 'New Deployment')
deployment
>>> Deployment('New Deployment')
classmethod create_from_leaderboard(model_id, label, description=None, default_prediction_server_id=None, importance=None, prediction_threshold=None, status=None, max_wait=600)

Create a deployment from a Leaderboard.

Added in version v2.17.

Parameters:
  • model_id (str) – id of the Leaderboard to deploy

  • label (str) – a human-readable label of the deployment

  • description (Optional[str]) – a human-readable description of the deployment

  • default_prediction_server_id (Optional[str]) – an identifier of a prediction server to be used as the default prediction server

  • importance (Optional[str]) – deployment importance

  • prediction_threshold (Optional[float]) – threshold used for binary classification in predictions

  • status (Optional[str]) – deployment status

  • max_wait (Optional[int]) – The amount of seconds to wait for successful resolution of a deployment creation job. Deployment supports making predictions only after a deployment creating job has successfully finished.

Returns:

deployment – The created deployment

Return type:

Deployment

Examples

from datarobot import Project, Deployment
project = Project.get('5506fcd38bd88f5953219da0')
model = project.get_models()[0]
deployment = Deployment.create_from_leaderboard(model.id, 'New Deployment')
deployment
>>> Deployment('New Deployment')
classmethod create_from_custom_model_version(custom_model_version_id, label, description=None, default_prediction_server_id=None, max_wait=600, importance=None)

Create a deployment from a DataRobot custom model image.

Parameters:
  • custom_model_version_id (str) – The ID of the DataRobot custom model version to deploy. The version must have a base_environment_id.

  • label (str) – A label of the deployment.

  • description (Optional[str]) – A description of the deployment.

  • default_prediction_server_id (str) – An identifier of a prediction server to be used as the default prediction server. Required for SaaS users and optional for Self-Managed users.

  • max_wait (Optional[int]) – Seconds to wait for successful resolution of a deployment creation job. Deployment supports making predictions only after a deployment creating job has successfully finished.

  • importance (Optional[str]) – Deployment importance level.

Returns:

deployment – The created deployment

Return type:

Deployment

classmethod create_from_registered_model_version(model_package_id, label, description=None, default_prediction_server_id=None, prediction_environment_id=None, importance=None, user_provided_id=None, additional_metadata=None, max_wait=600)

Create a deployment from a DataRobot model package (version).

Parameters:
  • model_package_id (str) – The ID of the DataRobot model package (also known as a registered model version) to deploy.

  • label (str) – A human readable label of the deployment.

  • description (Optional[str]) – A human readable description of the deployment.

  • default_prediction_server_id (Optional[str]) – an identifier of a prediction server to be used as the default prediction server When working with prediction environments, default prediction server Id should not be provided

  • prediction_environment_id (Optional[str]) – An identifier of a prediction environment to be used for model deployment.

  • importance (Optional[str]) – Deployment importance level.

  • user_provided_id (Optional[str]) – A user-provided unique ID associated with a deployment definition in a remote git repository.

  • additional_metadata (dict, optional) – ‘Key/Value pair dict, with additional metadata’

  • max_wait (Optional[int]) – The amount of seconds to wait for successful resolution of a deployment creation job. Deployment supports making predictions only after a deployment creating job has successfully finished.

Returns:

deployment – The created deployment

Return type:

Deployment

classmethod list(order_by=None, search=None, filters=None, offset=0, limit=0)

List all deployments a user can view.

Added in version v2.17.

Parameters:
  • order_by (Optional[str]) –

    (New in version v2.18) the order to sort the deployment list by, defaults to label

    Allowed attributes to sort by are:

    • label

    • serviceHealth

    • modelHealth

    • accuracyHealth

    • recentPredictions

    • lastPredictionTimestamp

    If the sort attribute is preceded by a hyphen, deployments will be sorted in descending order, otherwise in ascending order.

    For health related sorting, ascending means failing, warning, passing, unknown.

  • search (Optional[str]) – (New in version v2.18) case insensitive search against deployment’s label and description.

  • filters (Optional[datarobot.models.deployment.DeploymentListFilters]) – (New in version v2.20) an object containing all filters that you’d like to apply to the resulting list of deployments. See DeploymentListFilters for details on usage.

  • offset (Optional[int]) – The starting offset of the results. The default is 0.

  • limit (Optional[int]) – The maximum number of objects to return. The default is 0 to maintain previous behavior. The default on the server is 20, with a maximum of 100.

Returns:

deployments – a list of deployments the user can view

Return type:

list

Examples

from datarobot import Deployment
deployments = Deployment.list()
deployments
>>> [Deployment('New Deployment'), Deployment('Previous Deployment')]
from datarobot import Deployment
from datarobot.enums import DEPLOYMENT_SERVICE_HEALTH_STATUS
filters = DeploymentListFilters(
    role='OWNER',
    service_health=[DEPLOYMENT_SERVICE_HEALTH.FAILING]
)
filtered_deployments = Deployment.list(filters=filters)
filtered_deployments
>>> [Deployment('Deployment I Own w/ Failing Service Health')]
classmethod get(deployment_id)

Get information about a deployment.

Added in version v2.17.

Parameters:

deployment_id (str) – the id of the deployment

Returns:

deployment – the queried deployment

Return type:

Deployment

Examples

from datarobot import Deployment
deployment = Deployment.get(deployment_id='5c939e08962d741e34f609f0')
deployment.id
>>>'5c939e08962d741e34f609f0'
deployment.label
>>>'New Deployment'
predict_batch(source, passthrough_columns=None, download_timeout=None, download_read_timeout=None, upload_read_timeout=None)

A convenience method for making predictions with csv file or pandas DataFrame using a batch prediction job.

For advanced usage, use datarobot.models.BatchPredictionJob directly.

Added in version v3.0.

Parameters:
  • source (str, pd.DataFrame or file object) – Pass a filepath, file, or DataFrame for making batch predictions.

  • passthrough_columns (Optional[List[str]]) – Keep these columns from the scoring dataset in the scored dataset. This is useful for correlating predictions with source data.

  • download_timeout (Optional[int]) – Wait this many seconds for the download to become available. See datarobot.models.BatchPredictionJob.score().

  • download_read_timeout (Optional[int]) – Wait this many seconds for the server to respond between chunks. See datarobot.models.BatchPredictionJob.score().

  • upload_read_timeout (Optional[int]) – Wait this many seconds for the server to respond after a whole dataset upload. See datarobot.models.BatchPredictionJob.score().

Returns:

Prediction results in a pandas DataFrame.

Return type:

pd.DataFrame

Raises:

InvalidUsageError – If the source parameter cannot be determined to be a filepath, file, or DataFrame.

Examples

from datarobot.models.deployment import Deployment

deployment = Deployment.get("<MY_DEPLOYMENT_ID>")
prediction_results_as_dataframe = deployment.predict_batch(
    source="./my_local_file.csv",
)
get_uri()
Returns:

url – Deployment’s overview URI

Return type:

str

update(label=None, description=None, importance=None)

Update the label and description of this deployment. :rtype: None

Added in version v2.19.

delete()

Delete this deployment. :rtype: None

Added in version v2.17.

activate(max_wait=600)

Activates this deployment. When succeeded, deployment status become active.

Added in version v2.29.

Parameters:

max_wait (Optional[int]) – The maximum time to wait for deployment activation to complete before erroring

Return type:

None

deactivate(max_wait=600)

Deactivates this deployment. When succeeded, deployment status become inactive.

Added in version v2.29.

Parameters:

max_wait (Optional[int]) – The maximum time to wait for deployment deactivation to complete before erroring

Return type:

None

replace_model(new_model_id, reason, max_wait=600, new_registered_model_version_id=None)
Replace the model used in this deployment. To confirm model replacement eligibility, use

validate_replacement_model() beforehand.

Added in version v2.17.

Model replacement is an asynchronous process, which means some preparatory work may be performed after the initial request is completed. This function will not return until all preparatory work is fully finished.

Predictions made against this deployment will start using the new model as soon as the request is completed. There will be no interruption for predictions throughout the process.

Parameters:
  • new_model_id (Optional[str]) – The id of the new model to use. If replacing the deployment’s model with a CustomInferenceModel, a specific CustomModelVersion ID must be used. If None, new_registered_model_version_id must be specified.

  • reason (MODEL_REPLACEMENT_REASON) – The reason for the model replacement. Must be one of ‘ACCURACY’, ‘DATA_DRIFT’, ‘ERRORS’, ‘SCHEDULED_REFRESH’, ‘SCORING_SPEED’, or ‘OTHER’. This value will be stored in the model history to keep track of why a model was replaced

  • max_wait (Optional[int]) – (new in version 2.22) The maximum time to wait for model replacement job to complete before erroring

  • new_registered_model_version_id (Optional[str]) – (new in version 3.4) The registered model version (model package) ID of the new model to use. Must be passed if new_model_id is None.

Return type:

None

Examples

from datarobot import Deployment
from datarobot.enums import MODEL_REPLACEMENT_REASON
deployment = Deployment.get(deployment_id='5c939e08962d741e34f609f0')
deployment.model['id'], deployment.model['type']
>>>('5c0a979859b00004ba52e431', 'Decision Tree Classifier (Gini)')

deployment.replace_model('5c0a969859b00004ba52e41b', MODEL_REPLACEMENT_REASON.ACCURACY)
deployment.model['id'], deployment.model['type']
>>>('5c0a969859b00004ba52e41b', 'Support Vector Classifier (Linear Kernel)')
perform_model_replace(new_registered_model_version_id, reason, max_wait=600)
Replace the model used in this deployment. To confirm model replacement eligibility, use

validate_replacement_model() beforehand.

Added in version v3.4.

Model replacement is an asynchronous process, which means some preparatory work may be performed after the initial request is completed. This function will not return until all preparatory work is fully finished.

Predictions made against this deployment will start using the new model as soon as the request is completed. There will be no interruption for predictions throughout the process.

Parameters:
  • new_registered_model_version_id (str) – The registered model version (model package) ID of the new model to use.

  • reason (MODEL_REPLACEMENT_REASON) – The reason for the model replacement. Must be one of ‘ACCURACY’, ‘DATA_DRIFT’, ‘ERRORS’, ‘SCHEDULED_REFRESH’, ‘SCORING_SPEED’, or ‘OTHER’. This value will be stored in the model history to keep track of why a model was replaced

  • max_wait (Optional[int]) – The maximum time to wait for model replacement job to complete before erroring

Return type:

None

Examples

from datarobot import Deployment
from datarobot.enums import MODEL_REPLACEMENT_REASON
deployment = Deployment.get(deployment_id='5c939e08962d741e34f609f0')
deployment.model_package['id']
>>>'5c0a979859b00004ba52e431'

deployment.perform_model_replace('5c0a969859b00004ba52e41b', MODEL_REPLACEMENT_REASON.ACCURACY)
deployment.model_package['id']
>>>'5c0a969859b00004ba52e41b'
validate_replacement_model(new_model_id=None, new_registered_model_version_id=None)

Validate a model can be used as the replacement model of the deployment.

Added in version v2.17.

Parameters:
  • new_model_id (Optional[str]) – the id of the new model to validate

  • new_registered_model_version_id (Optional[str]) – (new in version 3.4) The registered model version (model package) ID of the new model to use.

Return type:

Tuple[str, str, Dict[str, Any]]

Returns:

  • status (str) – status of the validation, will be one of ‘passing’, ‘warning’ or ‘failing’. If the status is passing or warning, use replace_model() to perform a model replacement. If the status is failing, refer to checks for more detail on why the new model cannot be used as a replacement.

  • message (str) – message for the validation result

  • checks (dict) – explain why the new model can or cannot replace the deployment’s current model

get_features()

Retrieve the list of features needed to make predictions on this deployment.

Notes

Each feature dict contains the following structure:

  • name : str, feature name

  • feature_type : str, feature type

  • importance : float, numeric measure of the relationship strength between the feature and target (independent of model or other features)

  • date_format : str or None, the date format string for how this feature was interpreted, null if not a date feature, compatible with https://docs.python.org/2/library/time.html#time.strftime.

  • known_in_advance : bool, whether the feature was selected as known in advance in a time series model, false for non-time series models.

Returns:

features – a list of feature dict

Return type:

list

Examples

from datarobot import Deployment
deployment = Deployment.get(deployment_id='5c939e08962d741e34f609f0')
features = deployment.get_features()
features[0]['feature_type']
>>>'Categorical'
features[0]['importance']
>>>0.133
submit_actuals(data, batch_size=10000)

Submit actuals for processing. The actuals submitted will be used to calculate accuracy metrics.

Parameters:
  • data (list or pandas.DataFrame)

  • batch_size (the max number of actuals in each request)

  • list (If data is a)

  • and (each item should be a dict-like object with the following keys)

  • pandas.DataFrame (values; if data is a)

  • columns (it should contain the following)

  • association_id (-) – max length 128 characters

  • actual_value (-) – should be numeric for deployments with regression models or string for deployments with classification model

  • was_acted_on (-) – could have affected the actual outcome

  • timestamp (-) – does not have a timezone, we assume it is UTC.

Raises:

ValueError – if input data is not a list of dict-like objects or a pandas.DataFrame if input data is empty

Return type:

None

Examples

from datarobot import Deployment, AccuracyOverTime
deployment = Deployment.get(deployment_id='5c939e08962d741e34f609f0')
data = [{
    'association_id': '439917',
    'actual_value': 'True',
    'was_acted_on': True
}]
deployment.submit_actuals(data)
submit_actuals_from_catalog_async(dataset_id, actual_value_column, association_id_column, dataset_version_id=None, timestamp_column=None, was_acted_on_column=None)

Submit actuals from AI Catalog for processing. The actuals submitted will be used to calculate accuracy metrics.

Parameters:
  • dataset_id (str,) – The ID of the source dataset.

  • dataset_version_id (Optional[str]) – The ID of the dataset version to apply the query to. If not specified, the latest version associated with dataset_id is used.

  • association_id_column (str,) – The name of the column that contains a unique identifier used with a prediction.

  • actual_value_column (str,) – The name of the column that contains the actual value of a prediction.

  • was_acted_on_column (Optional[str],) – The name of the column that indicates if the prediction was acted on in a way that could have affected the actual outcome.

  • timestamp_column (Optional[str],) – The name of the column that contains datetime or string in RFC3339 format.

Returns:

status_check_job – Object contains all needed logic for a periodical status check of an async job.

Return type:

StatusCheckJob

Raises:

ValueError – if dataset_id not provided if actual_value_column not provided if association_id_column not provided

Examples

from datarobot import Deployment
deployment = Deployment.get(deployment_id='5c939e08962d741e34f609f0')
status_check_job = deployment.submit_actuals_from_catalog_async(data)
get_predictions_by_forecast_date_settings()

Retrieve predictions by forecast date settings of this deployment.

Added in version v2.27.

Returns:

settings – Predictions by forecast date settings of the deployment.

Return type:

ForecastDateSettings

update_predictions_by_forecast_date_settings(enable_predictions_by_forecast_date, forecast_date_column_name=None, forecast_date_format=None, max_wait=600)

Update predictions by forecast date settings of this deployment.

Added in version v2.27.

Updating predictions by forecast date setting is an asynchronous process, which means some preparatory work may be performed after the initial request is completed. This function will not return until all preparatory work is fully finished.

Examples

# To set predictions by forecast date settings to the same default settings you see when using
# the DataRobot web application, you use your 'Deployment' object like this:
deployment.update_predictions_by_forecast_date_settings(
   enable_predictions_by_forecast_date=True,
   forecast_date_column_name="date (actual)",
   forecast_date_format="%Y-%m-%d",
)
Parameters:
  • enable_predictions_by_forecast_date (bool) – set to True if predictions by forecast date is to be turned on or set to ‘’False’’ if predictions by forecast date is to be turned off.

  • forecast_date_column_name (string, optional) – The column name in prediction datasets to be used as forecast date. If ‘’enable_predictions_by_forecast_date’’ is set to ‘’False’’, then the parameter will be ignored.

  • forecast_date_format (string, optional) – The datetime format of the forecast date column in prediction datasets. If ‘’enable_predictions_by_forecast_date’’ is set to ‘’False’’, then the parameter will be ignored.

  • max_wait (Optional[int]) – seconds to wait for successful

Return type:

None

get_challenger_models_settings()

Retrieve challenger models settings of this deployment.

Added in version v2.27.

Returns:

settings

Return type:

ChallengerModelsSettings

update_challenger_models_settings(challenger_models_enabled, max_wait=600)

Update challenger models settings of this deployment.

Added in version v2.27.

Updating challenger models setting is an asynchronous process, which means some preparatory work may be performed after the initial request is completed. This function will not return until all preparatory work is fully finished.

Parameters:
  • challenger_models_enabled (bool) – set to True if challenger models is to be turned on or set to ‘’False’’ if challenger models is to be turned off

  • max_wait (Optional[int]) – seconds to wait for successful resolution

Return type:

None

get_segment_analysis_settings()

Retrieve segment analysis settings of this deployment.

Added in version v2.27.

Returns:

settings

Return type:

SegmentAnalysisSettings

update_segment_analysis_settings(segment_analysis_enabled, segment_analysis_attributes=None, max_wait=600)

Update segment analysis settings of this deployment.

Added in version v2.27.

Updating segment analysis setting is an asynchronous process, which means some preparatory work may be performed after the initial request is completed. This function will not return until all preparatory work is fully finished.

Parameters:
  • segment_analysis_enabled (bool) – set to True if segment analysis is to be turned on or set to ‘’False’’ if segment analysis is to be turned off

  • segment_analysis_attributes (Optional[List]) – A list of strings that gives the segment attributes selected for tracking.

  • max_wait (Optional[int]) – seconds to wait for successful resolution

Return type:

None

get_bias_and_fairness_settings()

Retrieve bias and fairness settings of this deployment.

..versionadded:: v3.2.0

Returns:

settings

Return type:

BiasAndFairnessSettings

update_bias_and_fairness_settings(protected_features, fairness_metric_set, fairness_threshold, preferable_target_value, max_wait=600)

Update bias and fairness settings of this deployment.

..versionadded:: v3.2.0

Updating bias and fairness setting is an asynchronous process, which means some preparatory work may be performed after the initial request is completed. This function will not return until all preparatory work is fully finished.

Parameters:
  • protected_features (List[str]) – A list of features to mark as protected.

  • preferable_target_value (bool) – A target value that should be treated as a positive outcome for the prediction.

  • fairness_metric_set (str) – Can be one of <datarobot.enums.FairnessMetricsSet>. The fairness metric used to calculate the fairness scores.

  • fairness_threshold (float) – Threshold value of the fairness metric. Cannot be less than 0 or greater than 1.

  • max_wait (Optional[int]) – seconds to wait for successful resolution

Return type:

None

get_challenger_replay_settings()

Retrieve challenger replay settings of this deployment.

Added in version v3.4.

Returns:

settings

Return type:

ChallengerReplaySettings

update_challenger_replay_settings(enabled, schedule=None)

Update challenger replay settings of this deployment.

Added in version v3.4.

Parameters:
  • enabled (bool) – If challenger replay is enabled.

  • schedule (Optional[Schedule]) – The recurring schedule for the challenger replay job.

Return type:

None

get_drift_tracking_settings()

Retrieve drift tracking settings of this deployment.

Added in version v2.17.

Returns:

settings

Return type:

DriftTrackingSettings

update_drift_tracking_settings(target_drift_enabled=None, feature_drift_enabled=None, max_wait=600)

Update drift tracking settings of this deployment.

Added in version v2.17.

Updating drift tracking setting is an asynchronous process, which means some preparatory work may be performed after the initial request is completed. This function will not return until all preparatory work is fully finished.

Parameters:
  • target_drift_enabled (Optional[bool]) – if target drift tracking is to be turned on

  • feature_drift_enabled (Optional[bool]) – if feature drift tracking is to be turned on

  • max_wait (Optional[int]) – seconds to wait for successful resolution

Return type:

None

get_association_id_settings()

Retrieve association ID setting for this deployment.

Added in version v2.19.

Returns:

association_id_settings

Return type:

str

update_association_id_settings(column_names=None, required_in_prediction_requests=None, max_wait=600)

Update association ID setting for this deployment.

Added in version v2.19.

Parameters:
  • column_names (list[string], optional) – name of the columns to be used as association ID, currently only support a list of one string

  • required_in_prediction_requests (Optional[bool]) – whether the association ID column is required in prediction requests

  • max_wait (Optional[int]) – seconds to wait for successful resolution

Return type:

None

get_predictions_data_collection_settings()

Retrieve predictions data collection settings of this deployment.

Added in version v2.21.

Returns:

predictions_data_collection_settings

Return type:

dict in the following format:

See also

datarobot.models.Deployment.update_predictions_data_collection_settings

Method to update existing predictions data collection settings.

update_predictions_data_collection_settings(enabled, max_wait=600)

Update predictions data collection settings of this deployment.

Added in version v2.21.

Updating predictions data collection setting is an asynchronous process, which means some preparatory work may be performed after the initial request is completed. This function will not return until all preparatory work is fully finished.

Parameters:
  • enabled (bool) – if predictions data collection is to be turned on

  • max_wait (Optional[int]) – seconds to wait for successful resolution

Return type:

None

get_prediction_warning_settings()

Retrieve prediction warning settings of this deployment.

Added in version v2.19.

Returns:

settings

Return type:

PredictionWarningSettings

update_prediction_warning_settings(prediction_warning_enabled, use_default_boundaries=None, lower_boundary=None, upper_boundary=None, max_wait=600)

Update prediction warning settings of this deployment.

Added in version v2.19.

Parameters:
  • prediction_warning_enabled (bool) – If prediction warnings should be turned on.

  • use_default_boundaries (Optional[bool]) – If default boundaries of the model should be used for the deployment.

  • upper_boundary (Optional[float]) – All predictions greater than provided value will be considered anomalous

  • lower_boundary (Optional[float]) – All predictions less than provided value will be considered anomalous

  • max_wait (Optional[int]) – seconds to wait for successful resolution

Return type:

None

get_prediction_intervals_settings()

Retrieve prediction intervals settings for this deployment.

Added in version v2.19.

Notes

Note that prediction intervals are only supported for time series deployments.

Returns:

settings

Return type:

PredictionIntervalsSettings

update_prediction_intervals_settings(percentiles, enabled=True, max_wait=600)

Update prediction intervals settings for this deployment.

Added in version v2.19.

Notes

Updating prediction intervals settings is an asynchronous process, which means some preparatory work may be performed before the settings request is completed. This function will not return until all work is fully finished.

Note that prediction intervals are only supported for time series deployments.

Parameters:
  • percentiles (list[int]) – The prediction intervals percentiles to enable for this deployment. Currently we only support setting one percentile at a time.

  • enabled (Optional[bool] (defaults to True)) – Whether to enable showing prediction intervals in the results of predictions requested using this deployment.

  • max_wait (Optional[int]) – seconds to wait for successful resolution

Raises:
  • AssertionError – If percentiles is in an invalid format

  • AsyncFailureError – If any of the responses from the server are unexpected

  • AsyncProcessUnsuccessfulError – If the prediction intervals calculation job has failed or has been cancelled.

  • AsyncTimeoutError – If the prediction intervals calculation job did not resolve in time

Return type:

None

get_health_settings()

Retrieve health settings of this deployment.

Added in version v3.4.

Returns:

settings

Return type:

HealthSettings

update_health_settings(service=None, data_drift=None, accuracy=None, fairness=None, custom_metrics=None, predictions_timeliness=None, actuals_timeliness=None)

Update health settings of this deployment.

Added in version v3.4.

Parameters:
  • service (dict) – Service health settings.

  • data_drift (dict) – Data drift health settings.

  • accuracy (dict) – Accuracy health settings.

  • fairness (dict) – Fairness health settings.

  • custom_metrics (dict) – Custom metrics health settings.

  • predictions_timeliness (dict) – Predictions timeliness health settings.

  • actuals_timeliness (dict) – Actuals timeliness health settings.

Return type:

HealthSettings

get_default_health_settings()

Retrieve default health settings of this deployment.

Added in version v3.4.

Returns:

settings

Return type:

HealthSettings

get_service_stats(model_id=None, start_time=None, end_time=None, execution_time_quantile=None, response_time_quantile=None, slow_requests_threshold=None, segment_attribute=None, segment_value=None)

Retrieves values of many service stat metrics aggregated over a time period.

Added in version v2.18.

Parameters:
  • model_id (Optional[str]) – the id of the model

  • start_time (datetime, optional) – start of the time period

  • end_time (datetime, optional) – end of the time period

  • execution_time_quantile (Optional[float]) – quantile for executionTime, defaults to 0.5

  • response_time_quantile (Optional[float]) – quantile for responseTime, defaults to 0.5

  • slow_requests_threshold (Optional[float]) – threshold for slowRequests, defaults to 1000

  • segment_attribute (Optional[str]) – (New in Version v3.6) the segment attribute

  • segment_value (Optional[str]) – (New in Version v3.6) the segment value

Returns:

service_stats – the queried service stats metrics information

Return type:

ServiceStats

get_service_stats_over_time(metric=None, model_id=None, start_time=None, end_time=None, bucket_size=None, quantile=None, threshold=None, segment_attribute=None, segment_value=None)

Retrieves values of a single service stat metric over a time period.

Added in version v2.18.

Parameters:
  • metric (SERVICE_STAT_METRIC, optional) – the service stat metric to retrieve

  • model_id (Optional[str]) – the id of the model

  • start_time (datetime, optional) – start of the time period

  • end_time (datetime, optional) – end of the time period

  • bucket_size (Optional[str]) – time duration of a bucket, in ISO 8601 time duration format

  • quantile (Optional[float]) – quantile for ‘executionTime’ or ‘responseTime’, ignored when querying other metrics

  • threshold (Optional[int]) – threshold for ‘slowQueries’, ignored when querying other metrics

  • segment_attribute (Optional[str]) – (New in Version v3.6) the segment attribute

  • segment_value (Optional[str]) – (New in Version v3.6) the segment value

Returns:

service_stats_over_time – the queried service stats metric over time information

Return type:

ServiceStatsOverTime

get_target_drift(model_id=None, start_time=None, end_time=None, metric=None, segment_attribute=None, segment_value=None)

Retrieve target drift information over a certain time period.

Added in version v2.21.

Parameters:
  • model_id (str) – the id of the model

  • start_time (datetime) – start of the time period

  • end_time (datetime) – end of the time period

  • metric (str) – (New in version v2.22) metric used to calculate the drift score

  • segment_attribute (Optional[str]) – (New in Version v3.6) the segment attribute

  • segment_value (Optional[str]) – (New in Version v3.6) the segment value

Returns:

target_drift – the queried target drift information

Return type:

TargetDrift

get_feature_drift(model_id=None, start_time=None, end_time=None, metric=None, segment_attribute=None, segment_value=None)

Retrieve drift information for deployment’s features over a certain time period.

Added in version v2.21.

Parameters:
  • model_id (str) – the id of the model

  • start_time (datetime) – start of the time period

  • end_time (datetime) – end of the time period

  • metric (str) – (New in version v2.22) The metric used to calculate the drift score. Allowed values include psi, kl_divergence, dissimilarity, hellinger, and js_divergence.

  • segment_attribute (Optional[str]) – (New in Version v3.6) the segment attribute

  • segment_value (Optional[str]) – (New in Version v3.6) the segment value

Returns:

feature_drift_data – the queried feature drift information

Return type:

[FeatureDrift]

get_predictions_over_time(model_ids=None, start_time=None, end_time=None, bucket_size=None, target_classes=None, include_percentiles=False, segment_attribute=None, segment_value=None)

Retrieve stats of deployment’s prediction response over a certain time period.

Added in version v3.2.

Parameters:
  • model_ids (list[str]) – ID of models to retrieve prediction stats

  • start_time (datetime) – start of the time period

  • end_time (datetime) – end of the time period

  • bucket_size (BUCKET_SIZE) – time duration of each bucket

  • target_classes (list[str]) – class names of target, only for deployments with multiclass target

  • include_percentiles (bool) – if the returned data includes percentiles, only for a deployment with a binary and regression target

  • segment_attribute (Optional[str]) – (New in Version v3.6) the segment attribute

  • segment_value (Optional[str]) – (New in Version v3.6) the segment value

Returns:

predictions_over_time – the queried predictions over time information

Return type:

PredictionsOverTime

Examples

from datarobot import Deployment
deployment = Deployment.get(deployment_id='5c939e08962d741e34f609f0')
predictions_over_time = deployment.get_predictions_over_time()
predictions_over_time.buckets[0]['mean_predicted_value']
>>>0.3772
predictions_over_time.buckets[0]['row_count']
>>>2000
get_accuracy(model_id=None, start_time=None, end_time=None, start=None, end=None, target_classes=None, segment_attribute=None, segment_value=None)

Retrieves values of many accuracy metrics aggregated over a time period.

Added in version v2.18.

Parameters:
  • model_id (str) – the id of the model

  • start_time (datetime) – start of the time period

  • end_time (datetime) – end of the time period

  • target_classes (list[str], optional) – Optional list of target class strings

  • segment_attribute (Optional[str]) – (New in Version v3.6) the segment attribute

  • segment_value (Optional[str]) – (New in Version v3.6) the segment value

Returns:

accuracy – the queried accuracy metrics information

Return type:

Accuracy

get_accuracy_over_time(metric=None, model_id=None, start_time=None, end_time=None, bucket_size=None, target_classes=None, segment_attribute=None, segment_value=None)

Retrieves values of a single accuracy metric over a time period.

Added in version v2.18.

Parameters:
  • metric (ACCURACY_METRIC) – the accuracy metric to retrieve

  • model_id (str) – the id of the model

  • start_time (datetime) – start of the time period

  • end_time (datetime) – end of the time period

  • bucket_size (str) – time duration of a bucket, in ISO 8601 time duration format

  • target_classes (list[str], optional) – Optional list of target class strings

  • segment_attribute (Optional[str]) – (New in Version v3.6) the segment attribute

  • segment_value (Optional[str]) – (New in Version v3.6) the segment value

Returns:

accuracy_over_time – the queried accuracy metric over time information

Return type:

AccuracyOverTime

get_predictions_vs_actuals_over_time(model_ids=None, start_time=None, end_time=None, bucket_size=None, target_classes=None, segment_attribute=None, segment_value=None)

Retrieve information for deployment’s predictions vs actuals over a certain time period.

Added in version v3.3.

Parameters:
  • model_ids (list[str]) – The ID of models to retrieve predictions vs actuals stats for.

  • start_time (datetime) – Start of the time period.

  • end_time (datetime) – End of the time period.

  • bucket_size (BUCKET_SIZE) – Time duration of each bucket.

  • target_classes (list[str]) – Class names of target, only for deployments with a multiclass target.

  • segment_attribute (Optional[str]) – (New in Version v3.6) the segment attribute

  • segment_value (Optional[str]) – (New in Version v3.6) the segment value

Returns:

predictions_vs_actuals_over_time – The queried predictions vs actuals over time information.

Return type:

PredictionsVsActualsOverTime

Examples

from datarobot import Deployment
deployment = Deployment.get(deployment_id='5c939e08962d741e34f609f0')
predictions_over_time = deployment.get_predictions_vs_actuals_over_time()
predictions_over_time.buckets[0]['mean_actual_value']
>>>0.6673
predictions_over_time.buckets[0]['row_count_with_actual']
>>>500
get_fairness_scores_over_time(start_time=None, end_time=None, bucket_size=None, model_id=None, protected_feature=None, fairness_metric=None)

Retrieves values of a single fairness score over a time period.

Added in version v3.2.

Parameters:
  • model_id (str) – the id of the model

  • start_time (datetime) – start of the time period

  • end_time (datetime) – end of the time period

  • bucket_size (str) – time duration of a bucket, in ISO 8601 time duration format

  • protected_feature (str) – name of protected feature

  • fairness_metric (str) – A consolidation of the fairness metrics by the use case.

Returns:

fairness_scores_over_time – the queried fairness score over time information

Return type:

FairnessScoresOverTime

update_secondary_dataset_config(secondary_dataset_config_id, credential_ids=None)

Update the secondary dataset config used by Feature discovery model for a given deployment.

Added in version v2.23.

Parameters:
  • secondary_dataset_config_id (str) – Id of the secondary dataset config

  • credential_ids (list or None) – List of DatasetsCredentials used by the secondary datasets

Return type:

str

Examples

from datarobot import Deployment
deployment = Deployment(deployment_id='5c939e08962d741e34f609f0')
config = deployment.update_secondary_dataset_config('5df109112ca582033ff44084')
config
>>> '5df109112ca582033ff44084'
get_secondary_dataset_config()

Get the secondary dataset config used by Feature discovery model for a given deployment.

Added in version v2.23.

Returns:

secondary_dataset_config – Id of the secondary dataset config

Return type:

SecondaryDatasetConfigurations

Examples

from datarobot import Deployment
deployment = Deployment(deployment_id='5c939e08962d741e34f609f0')
deployment.update_secondary_dataset_config('5df109112ca582033ff44084')
config = deployment.get_secondary_dataset_config()
config
>>> '5df109112ca582033ff44084'
get_prediction_results(model_id=None, start_time=None, end_time=None, actuals_present=None, offset=None, limit=None)

Retrieve a list of prediction results of the deployment.

Added in version v2.24.

Parameters:
  • model_id (str) – the id of the model

  • start_time (datetime) – start of the time period

  • end_time (datetime) – end of the time period

  • actuals_present (bool) – filters predictions results to only those who have actuals present or with missing actuals

  • offset (int) – this many results will be skipped

  • limit (int) – at most this many results are returned

Returns:

prediction_results – a list of prediction results

Return type:

list[dict]

Examples

from datarobot import Deployment
deployment = Deployment.get(deployment_id='5c939e08962d741e34f609f0')
results = deployment.get_prediction_results()
download_prediction_results(filepath, model_id=None, start_time=None, end_time=None, actuals_present=None, offset=None, limit=None)

Download prediction results of the deployment as a CSV file.

Added in version v2.24.

Parameters:
  • filepath (str) – path of the csv file

  • model_id (str) – the id of the model

  • start_time (datetime) – start of the time period

  • end_time (datetime) – end of the time period

  • actuals_present (bool) – filters predictions results to only those who have actuals present or with missing actuals

  • offset (int) – this many results will be skipped

  • limit (int) – at most this many results are returned

Return type:

None

Examples

from datarobot import Deployment
deployment = Deployment.get(deployment_id='5c939e08962d741e34f609f0')
results = deployment.download_prediction_results('path_to_prediction_results.csv')
download_scoring_code(filepath, source_code=False, include_agent=False, include_prediction_explanations=False, include_prediction_intervals=False, max_wait=600)

Retrieve scoring code of the current deployed model.

Added in version v2.24.

Notes

When setting include_agent or include_predictions_explanations or include_prediction_intervals to True, it can take a considerably longer time to download the scoring code.

Parameters:
  • filepath (str) – path of the scoring code file

  • source_code (bool) – whether source code or binary of the scoring code will be retrieved

  • include_agent (bool) – whether the scoring code retrieved will include tracking agent

  • include_prediction_explanations (bool) – whether the scoring code retrieved will include prediction explanations

  • include_prediction_intervals (bool) – whether the scoring code retrieved will support prediction intervals

  • max_wait (Optional[int]) – Seconds to wait for successful resolution of a deployment creation job. Deployment supports making predictions only after a deployment creating job has successfully finished

Return type:

None

Examples

from datarobot import Deployment
deployment = Deployment.get(deployment_id='5c939e08962d741e34f609f0')
results = deployment.download_scoring_code('path_to_scoring_code.jar')
download_model_package_file(filepath, compute_all_ts_intervals=False)

Retrieve model package file (mlpkg) of the current deployed model.

Added in version v3.3.

Parameters:
  • filepath (str) – The file path of the model package file.

  • compute_all_ts_intervals (bool) – Includes all time series intervals into the built Model Package (.mlpkg) if set to True.

Return type:

None

Examples

from datarobot import Deployment
deployment = Deployment.get(deployment_id='5c939e08962d741e34f609f0')
deployment.download_model_package_file('path_to_model_package.mlpkg')
delete_monitoring_data(model_id, start_time=None, end_time=None, max_wait=600)

Delete deployment monitoring data.

Parameters:
  • model_id (str) – id of the model to delete monitoring data

  • start_time (datetime, optional) – start of the time period to delete monitoring data

  • end_time (datetime, optional) – end of the time period to delete monitoring data

  • max_wait (Optional[int]) – seconds to wait for successful resolution

Return type:

None

list_shared_roles(id=None, name=None, share_recipient_type=None, limit=100, offset=0)

Get a list of users, groups and organizations that have an access to this user blueprint

Parameters:
  • id (Optional[str]) – Only return the access control information for a organization, group or user with this ID.

  • name (string, Optional) – Only return the access control information for a organization, group or user with this name.

  • share_recipient_type (enum(``’user’, ``'group', 'organization'), Optional) – Only returns results with the given recipient type.

  • limit (int (Default=0)) – At most this many results are returned.

  • offset (int (Default=0)) – This many results will be skipped.

Return type:

List[DeploymentSharedRole]

update_shared_roles(roles)

Share a deployment with a user, group, or organization

Parameters:

roles (list(or(GrantAccessControlWithUsernameValidator, GrantAccessControlWithIdValidator, SharingRole))) – Array of GrantAccessControl objects, up to maximum 100 objects.

Return type:

None

share(roles)

Share a deployment with a user, group, or organization

Parameters:

roles (list(SharingRole)) – Array of SharingRole objects.

Return type:

None

list_challengers()

Get a list of challengers for this deployment.

Added in version v3.4.

Return type:

list(Challenger)

get_champion_model_package()

Get a champion model package for this deployment.

Returns:

champion_model_package – A champion model package object.

Return type:

ChampionModelPackage

Examples

from datarobot import Deployment
deployment = Deployment.get(deployment_id='5c939e08962d741e34f609f0')
champion_model_package = deployment.get_champion_model_package()
list_prediction_data_exports(model_id=None, status=None, batch=None, offset=0, limit=100)

Retrieve a list of asynchronous prediction data exports.

Parameters:
  • model_id (Optional[str]) – The ID of the model used for prediction data export.

  • status (Optional[str]) – A prediction data export processing state.

  • batch (Optional[bool]) – If true, only return batch exports. If false, only return real-time exports. If not provided, return both real-time and batch exports.

  • limit (Optional[int]) – The maximum number of objects to return. The default is 100 (0 means no limit).

  • offset (Optional[int]) – The starting offset of the results. The default is 0.

Returns:

prediction_data_exports – A list of prediction data exports.

Return type:

List[PredictionDataExport]

list_actuals_data_exports(status=None, offset=0, limit=100)

Retrieve a list of asynchronous actuals data exports.

Parameters:
  • status (Optional[str]) – Actuals data export processing state.

  • limit (Optional[int]) – The maximum number of objects to return. The default is 100 (0 means no limit).

  • offset (Optional[int]) – The starting offset of the results. The default is 0.

Returns:

actuals_data_exports – A list of actuals data exports.

Return type:

List[ActualsDataExport]

list_training_data_exports()

Retrieve a list of successful training data exports.

Returns:

training_data_export – A list of training data exports.

Return type:

List[TrainingDataExport]

list_data_quality_exports(start, end, model_id=None, prediction_pattern=None, prompt_pattern=None, actual_pattern=None, order_by=None, order_metric=None, filter_metric=None, filter_value=None, offset=0, limit=100)

Retrieve a list of data-quality export records for a given deployment.

Added in version v3.6.

Parameters:
  • start (Union[str, datetime]) – The earliest time of the objects to return.

  • end (Union[str, datetime]) – The latest time of the objects to return.

  • model_id (Optional[str]) – The ID of the model.

  • prediction_pattern (Optional[str]) – The keywords to search in a predicted value for a text generation target.

  • prompt_pattern (Optional[str]) – The keywords to search in a prompt value for a text generation target.

  • actual_pattern (Optional[str]) – The keywords to search in an actual value for a text generation target.

  • order_by (Optional[str]) – The field to sort by (e.g. associationId, timestamp, or customMetrics). Use a leading ‘-’ to indicate descending order. When ordering by a custom-metric, must also specify ‘order_metric’. The default is None, which equates to ‘-timestamp’.

  • order_metric (Optional[str]) – When ‘order_by’ is a custom-metric, this specifies the custom-metric name or ID to use for ordering. The default is None.

  • filter_metric (Optional[str]) – Specifies the metric name or ID to use for matching. Must also use ‘filter_value’ to specify the value that must be matched. The default is None.

  • filter_value (Optional[str]) – Specifies the value associated with ‘filter_metric’ that must be matched. The default is None.

  • offset (Optional[int]) – The starting offset of the results. The default is 0.

  • limit (Optional[int]) – The maximum number of objects to return. The default is 100 (which is maximum).

Returns:

data_quality_exports – A list of DataQualityExport objects.

Return type:

list

Examples

from datarobot import Deployment

deployment = Deployment.get(deployment_id='5c939e08962d741e34f609f0')
data_quality_exports = deployment.list_data_quality_exports(start_time='2024-07-01', end_time='2024-08-01')
get_capabilities()

Get a list capabilities for this deployment.

Added in version v3.5.

Return type:

list(Capability)

Examples

from datarobot import Deployment
deployment = Deployment.get(deployment_id='5c939e08962d741e34f609f0')
capabilities = deployment.get_capabilities()
get_segment_attributes(monitoringType='serviceHealth')

Get a list of segment attributes for this deployment.

Added in version v3.6.

Parameters:

monitoringType (Optional[str]) – The monitoring type for which segment attributes are being retrieved.

Return type:

list(str)

Examples

from datarobot import Deployment
deployment = Deployment.get(deployment_id='5c939e08962d741e34f609f0')
segment_attributes = deployment.get_segment_attributes(DEPLOYMENT_MONITORING_TYPE.SERVICE_HEALTH)
get_segment_values(segment_attribute=None, limit=100, offset=0, search=None)

Get a list of segment values for this deployment.

Added in version v3.6.

Parameters:
  • segment_attribute (Optional[str]) – Represents the different ways that prediction requests can be viewed.

  • limit (int, Optional) – The maximum number of values to return.

  • offset (int, Optional) – The starting point of the values to be returned.

  • search (Optional[str]) – A string to filter the values.

Return type:

list(str)

Examples

from datarobot import Deployment
deployment = Deployment.get(deployment_id='5c939e08962d741e34f609f0')
segment_values = deployment.get_segment_values(segment_attribute=ReservedSegmentAttributes.CONSUMER)
get_moderation_events(limit=100, offset=0)

Get a list of moderation events for this deployment

Parameters:
  • limit (int (Default=100)) – The maximum number of values to return.

  • offset (int (Default=0)) – The starting point of the values to be returned.

Returns:

events

Return type:

List[MLOpsEvent]

get_accuracy_metrics_settings()

Get accuracy metrics settings for this deployment.

Returns:

accuracy_metrics – A list of deployment accuracy metric names.

Return type:

list(str)

Examples

from datarobot import Deployment

deployment = Deployment.get(deployment_id='5c939e08962d741e34f609f0')
accuracy_metrics = deployment.get_accuracy_metrics_settings()
update_accuracy_metrics_settings(accuracy_metrics)

Update accuracy metrics settings for this deployment.

Parameters:

accuracy_metrics (list(str)) – A list of accuracy metric names.

Returns:

accuracy_metrics – A list of deployment accuracy metric names.

Return type:

list(str)

Examples

from datarobot import Deployment
from datarobot.enums import ACCURACY_METRIC

deployment = Deployment.get(deployment_id='5c939e08962d741e34f609f0')
payload = [ACCURACY_METRIC.AUC, ACCURACY_METRIC.LOGLOSS]
accuracy_metrics = deployment.update_accuracy_metrics_settings(payload)
get_retraining_settings()

Retrieve retraining settings of this deployment.

Added in version v2.29.

Returns:

settings

Return type:

RetrainingSettings

Examples

from datarobot import Deployment

deployment = Deployment.get(deployment_id='5c939e08962d741e34f609f0')
retraining_settings = deployment.get_retraining_settings()
update_retraining_settings(retraining_user_id=<object object>, dataset_id=<object object>, prediction_environment_id=<object object>)

Update retraining settings of this deployment.

Added in version v2.29.

Parameters:
  • retraining_user_id (Optional[str]) – The retraining user ID.

  • dataset_id (Optional[str]) – The retraining dataset ID.

  • prediction_environment_id (Optional[str]) – The retraining prediction environment ID.

Return type:

None

Examples

from datarobot import Deployment

deployment = Deployment.get(deployment_id='5c939e08962d741e34f609f0')
deployment.update_retraining_settings(retaining_user_id='5c939e08962d741e34f609f0')
classmethod from_data(data)

Instantiate an object of this class using a dict.

Parameters:

data (dict) – Correctly snake_cased keys and their values.

Return type:

TypeVar(T, bound= APIObject)

classmethod from_server_data(data, keep_attrs=None)

Instantiate an object of this class using the data directly from the server, meaning that the keys may have the wrong camel casing

Parameters:
  • data (dict) – The directly translated dict of JSON from the server. No casing fixes have taken place

  • keep_attrs (iterable) – List, set or tuple of the dotted namespace notations for attributes to keep within the object structure even if their values are None

Return type:

TypeVar(T, bound= APIObject)

open_in_browser()

Opens class’ relevant web browser location. If default browser is not available the URL is logged.

Note: If text-mode browsers are used, the calling process will block until the user exits the browser.

Return type:

None

class datarobot.models.deployment.DeploymentListFilters
class datarobot.models.deployment.ServiceStats

Deployment service stats information.

Variables:
  • model_id (str) – the model used to retrieve service stats metrics

  • period (dict) – the time period used to retrieve service stats metrics

  • metrics (dict) – the service stats metrics

classmethod get(deployment_id, model_id=None, start_time=None, end_time=None, execution_time_quantile=None, response_time_quantile=None, segment_attribute=None, segment_value=None, slow_requests_threshold=None)

Retrieve value of service stat metrics over a certain time period.

Added in version v2.18.

Parameters:
  • deployment_id (str) – the id of the deployment

  • model_id (Optional[str]) – the id of the model

  • start_time (datetime, optional) – start of the time period

  • end_time (datetime, optional) – end of the time period

  • execution_time_quantile (Optional[float]) – quantile for executionTime, defaults to 0.5

  • response_time_quantile (Optional[float]) – quantile for responseTime, defaults to 0.5

  • segment_attribute (Optional[str]) – (New in Version v3.6) the segment attribute

  • segment_value (Optional[str]) – (New in Version v3.6) the segment value

  • slow_requests_threshold (Optional[float]) – threshold for slowRequests, defaults to 1000

Returns:

service_stats – the queried service stats metrics

Return type:

ServiceStats

class datarobot.models.deployment.ServiceStatsOverTime

Deployment service stats over time information.

Variables:
  • model_id (str) – the model used to retrieve accuracy metric

  • metric (str) – the service stat metric being retrieved

  • buckets (dict) – how the service stat metric changes over time

  • summary (dict) – summary for the service stat metric

classmethod get(deployment_id, metric=None, model_id=None, start_time=None, end_time=None, bucket_size=None, quantile=None, threshold=None, segment_attribute=None, segment_value=None)

Retrieve information about how a service stat metric changes over a certain time period.

Added in version v2.18.

Parameters:
  • deployment_id (str) – the id of the deployment

  • metric (SERVICE_STAT_METRIC, optional) – the service stat metric to retrieve

  • model_id (Optional[str]) – the id of the model

  • start_time (datetime, optional) – start of the time period

  • end_time (datetime, optional) – end of the time period

  • bucket_size (Optional[str]) – time duration of a bucket, in ISO 8601 time duration format

  • quantile (Optional[float]) – quantile for ‘executionTime’ or ‘responseTime’, ignored when querying other metrics

  • threshold (Optional[int]) – threshold for ‘slowQueries’, ignored when querying other metrics

  • segment_attribute (Optional[str]) – (New in Version v3.6) the segment attribute

  • segment_value (Optional[str]) – (New in Version v3.6) the segment value

Returns:

service_stats_over_time – the queried service stat over time information

Return type:

ServiceStatsOverTime

property bucket_values: OrderedDict[str, int | float | None]

The metric value for all time buckets, keyed by start time of the bucket.

Returns:

bucket_values

Return type:

OrderedDict

class datarobot.models.deployment.TargetDrift

Deployment target drift information.

Variables:
  • model_id (str) – the model used to retrieve target drift metric

  • period (dict) – the time period used to retrieve target drift metric

  • metric (str) – the data drift metric

  • target_name (str) – name of the target

  • drift_score (float) – target drift score

  • sample_size (int) – count of data points for comparison

  • baseline_sample_size (int) – count of data points for baseline

classmethod get(deployment_id, model_id=None, start_time=None, end_time=None, metric=None, segment_attribute=None, segment_value=None)

Retrieve target drift information over a certain time period.

Added in version v2.21.

Parameters:
  • deployment_id (str) – the id of the deployment

  • model_id (str) – the id of the model

  • start_time (datetime) – start of the time period

  • end_time (datetime) – end of the time period

  • metric (str) – (New in version v2.22) metric used to calculate the drift score

  • segment_attribute (Optional[str]) – (New in Version v3.6) the segment attribute

  • segment_value (Optional[str]) – (New in Version v3.6) the segment value

Returns:

target_drift – the queried target drift information

Return type:

TargetDrift

Examples

from datarobot import Deployment, TargetDrift
deployment = Deployment.get(deployment_id='5c939e08962d741e34f609f0')
target_drift = TargetDrift.get(deployment.id)
target_drift.period['end']
>>>'2019-08-01 00:00:00+00:00'
target_drift.drift_score
>>>0.03423
accuracy.target_name
>>>'readmitted'
class datarobot.models.deployment.FeatureDrift

Deployment feature drift information.

Variables:
  • model_id (str) – the model used to retrieve feature drift metric

  • period (dict) – the time period used to retrieve feature drift metric

  • metric (str) – the data drift metric

  • name (str) – name of the feature

  • drift_score (float) – feature drift score

  • sample_size (int) – count of data points for comparison

  • baseline_sample_size (int) – count of data points for baseline

classmethod list(deployment_id, model_id=None, start_time=None, end_time=None, metric=None, segment_attribute=None, segment_value=None)

Retrieve drift information for deployment’s features over a certain time period.

Added in version v2.21.

Parameters:
  • deployment_id (str) – the id of the deployment

  • model_id (str) – the id of the model

  • start_time (datetime) – start of the time period

  • end_time (datetime) – end of the time period

  • metric (str) – (New in version v2.22) metric used to calculate the drift score

  • segment_attribute (Optional[str]) – (New in Version v3.6) the segment attribute

  • segment_value (Optional[str]) – (New in Version v3.6) the segment value

Returns:

feature_drift_data – the queried feature drift information

Return type:

[FeatureDrift]

Examples

from datarobot import Deployment, TargetDrift
deployment = Deployment.get(deployment_id='5c939e08962d741e34f609f0')
feature_drift = FeatureDrift.list(deployment.id)[0]
feature_drift.period
>>>'2019-08-01 00:00:00+00:00'
feature_drift.drift_score
>>>0.252
feature_drift.name
>>>'age'
class datarobot.models.deployment.PredictionsOverTime

Deployment predictions over time information.

Variables:
  • baselines (List) – target baseline for each model queried

  • buckets (List) – predictions over time bucket for each model and bucket queried

classmethod get(deployment_id, model_ids=None, start_time=None, end_time=None, bucket_size=None, target_classes=None, include_percentiles=False, segment_attribute=None, segment_value=None)

Retrieve information for deployment’s prediction response over a certain time period.

Added in version v3.2.

Parameters:
  • deployment_id (str) – the id of the deployment

  • model_ids (list[str]) – ID of models to retrieve prediction stats

  • start_time (datetime) – start of the time period

  • end_time (datetime) – end of the time period

  • bucket_size (BUCKET_SIZE) – time duration of each bucket

  • target_classes (list[str]) – class names of target, only for deployments with multiclass target

  • include_percentiles (bool) – if the returned data includes percentiles, only for a deployment with a binary and regression target

  • segment_attribute (Optional[str]) – (New in Version v3.6) the segment attribute

  • segment_value (Optional[str]) – (New in Version v3.6) the segment value

Returns:

predictions_over_time – the queried predictions over time information

Return type:

PredictionsOverTime

class datarobot.models.deployment.Accuracy

Deployment accuracy information.

Variables:
  • model_id (str) – the model used to retrieve accuracy metrics

  • period (dict) – the time period used to retrieve accuracy metrics

  • metrics (dict) – the accuracy metrics

classmethod get(deployment_id, model_id=None, start_time=None, end_time=None, target_classes=None, segment_attribute=None, segment_value=None)

Retrieve values of accuracy metrics over a certain time period.

Added in version v2.18.

Parameters:
  • deployment_id (str) – the id of the deployment

  • model_id (str) – the id of the model

  • start_time (datetime) – start of the time period

  • end_time (datetime) – end of the time period

  • target_classes (list[str], optional) – Optional list of target class strings

  • segment_attribute (Optional[str]) – (New in Version v3.6) the segment attribute

  • segment_value (Optional[str]) – (New in Version v3.6) the segment value

Returns:

accuracy – the queried accuracy metrics information

Return type:

Accuracy

Examples

from datarobot import Deployment, Accuracy
deployment = Deployment.get(deployment_id='5c939e08962d741e34f609f0')
accuracy = Accuracy.get(deployment.id)
accuracy.period['end']
>>>'2019-08-01 00:00:00+00:00'
accuracy.metric['LogLoss']['value']
>>>0.7533
accuracy.metric_values['LogLoss']
>>>0.7533
property metric_values: Dict[str, int | None]

The value for all metrics, keyed by metric name.

Returns:

metric_values

Return type:

Dict

property metric_baselines: Dict[str, int | None]

The baseline value for all metrics, keyed by metric name.

Returns:

metric_baselines

Return type:

Dict

property percent_changes: Dict[str, int | None]

The percent change of value over baseline for all metrics, keyed by metric name.

Returns:

percent_changes

Return type:

Dict

class datarobot.models.deployment.AccuracyOverTime

Deployment accuracy over time information.

Variables:
  • model_id (str) – the model used to retrieve accuracy metric

  • metric (str) – the accuracy metric being retrieved

  • buckets (dict) – how the accuracy metric changes over time

  • summary (dict) – summary for the accuracy metric

  • baseline (dict) – baseline for the accuracy metric

classmethod get(deployment_id, metric=None, model_id=None, start_time=None, end_time=None, bucket_size=None, target_classes=None, segment_attribute=None, segment_value=None)

Retrieve information about how an accuracy metric changes over a certain time period.

Added in version v2.18.

Parameters:
  • deployment_id (str) – the id of the deployment

  • metric (ACCURACY_METRIC) – the accuracy metric to retrieve

  • model_id (str) – the id of the model

  • start_time (datetime) – start of the time period

  • end_time (datetime) – end of the time period

  • bucket_size (str) – time duration of a bucket, in ISO 8601 time duration format

  • target_classes (list[str], optional) – Optional list of target class strings

  • segment_attribute (Optional[str]) – (New in Version v3.6) the segment attribute

  • segment_value (Optional[str]) – (New in Version v3.6) the segment value

Returns:

accuracy_over_time – the queried accuracy metric over time information

Return type:

AccuracyOverTime

Examples

from datarobot import Deployment, AccuracyOverTime
from datarobot.enums import ACCURACY_METRICS
deployment = Deployment.get(deployment_id='5c939e08962d741e34f609f0')
accuracy_over_time = AccuracyOverTime.get(deployment.id, metric=ACCURACY_METRIC.LOGLOSS)
accuracy_over_time.metric
>>>'LogLoss'
accuracy_over_time.metric_values
>>>{datetime.datetime(2019, 8, 1): 0.73, datetime.datetime(2019, 8, 2): 0.55}
classmethod get_as_dataframe(deployment_id, metrics=None, model_id=None, start_time=None, end_time=None, bucket_size=None)

Retrieve information about how a list of accuracy metrics change over a certain time period as pandas DataFrame.

In the returned DataFrame, the columns corresponds to the metrics being retrieved; the rows are labeled with the start time of each bucket.

Parameters:
  • deployment_id (str) – the id of the deployment

  • metrics ([ACCURACY_METRIC]) – the accuracy metrics to retrieve

  • model_id (str) – the id of the model

  • start_time (datetime) – start of the time period

  • end_time (datetime) – end of the time period

  • bucket_size (str) – time duration of a bucket, in ISO 8601 time duration format

Returns:

accuracy_over_time

Return type:

pd.DataFrame

property bucket_values: Dict[datetime, int]

The metric value for all time buckets, keyed by start time of the bucket.

Returns:

bucket_values

Return type:

Dict

property bucket_sample_sizes: Dict[datetime, int]

The sample size for all time buckets, keyed by start time of the bucket.

Returns:

bucket_sample_sizes

Return type:

Dict

class datarobot.models.deployment.PredictionsVsActualsOverTime

Deployment predictions vs actuals over time information.

Variables:
  • summary (dict) – predictions vs actuals over time summary for all models and buckets queried

  • baselines (List) – target baseline for each model queried

  • buckets (List) – predictions vs actuals over time bucket for each model and bucket queried

  • segment_attribute (Optional[str]) – (New in Version v3.6) the segment attribute

  • segment_value (Optional[str]) – (New in Version v3.6) the segment value

classmethod get(deployment_id, model_ids=None, start_time=None, end_time=None, bucket_size=None, target_classes=None, segment_attribute=None, segment_value=None)

Retrieve information for deployment’s predictions vs actuals over a certain time period.

Added in version v3.3.

Parameters:
  • deployment_id (str) – the id of the deployment

  • model_ids (list[str]) – ID of models to retrieve predictions vs actuals stats

  • start_time (datetime) – start of the time period

  • end_time (datetime) – end of the time period

  • bucket_size (BUCKET_SIZE) – time duration of each bucket

  • target_classes (list[str]) – class names of target, only for deployments with multiclass target

  • segment_attribute (Optional[str]) – (New in Version v3.6) the segment attribute

  • segment_value (Optional[str]) – (New in Version v3.6) the segment value

Returns:

predictions_vs_actuals_over_time – the queried predictions vs actuals over time information

Return type:

PredictionsVsActualsOverTime

class datarobot.models.deployment.bias_and_fairness.FairnessScoresOverTime

Deployment fairness over time information.

Variables:
  • buckets (List) – fairness over time bucket for each model and bucket queried

  • summary (dict) – summary for the fairness score

  • protected_feature (str) – name of protected feature

  • fairnessThreshold (float) – threshold used to compute fairness results

  • modelId (str) – model id for which fairness is computed

  • modelPackageId (str) – model package (version) id for which fairness is computed

  • favorableTargetOutcome (bool) – preferable class of the target

classmethod get(deployment_id, model_id=None, start_time=None, end_time=None, bucket_size=None, fairness_metric=None, protected_feature=None)

Retrieve information for deployment’s fairness score response over a certain time period.

Added in version FUTURE.

Parameters:
  • deployment_id (str) – the id of the deployment

  • model_id (str) – id of models to retrieve fairness score stats

  • start_time (datetime) – start of the time period

  • end_time (datetime) – end of the time period

  • protected_feature (str) – name of the protected feature

  • fairness_metric (str) – A consolidation of the fairness metrics by the use case.

  • bucket_size (BUCKET_SIZE) – time duration of each bucket

Returns:

fairness_scores_over_time – the queried fairness score over time information

Return type:

FairnessScoresOverTime

class datarobot.models.deployment.DeploymentSharedRole
Parameters:
  • share_recipient_type ({'user', 'group', 'organization'}) – Describes the recipient type, either user, group, or organization.

  • role ({'CONSUMER', 'USER', 'OWNER'}) – The role of the org/group/user on this deployment.

  • id (str) – The ID of the recipient organization, group, or user.

  • name (str) – The name of the recipient organization, group, or user.

class datarobot.models.deployment.DeploymentGrantSharedRoleWithId
Parameters:
  • share_recipient_type ({'user', 'group', 'organization'}) – Describes the recipient type, either user, group, or organization.

  • role ({'OWNER', 'USER', 'OBSERVER', 'NO_ROLE'}) – The role of the recipient on this entity. One of OWNER, USER, OBSERVER, NO_ROLE. If NO_ROLE is specified, any existing role for the recipient will be removed.

  • id (str) – The ID of the recipient.

class datarobot.models.deployment.DeploymentGrantSharedRoleWithUsername
Parameters:
  • role (string) – The role of the recipient on this entity. One of OWNER, USER, CONSUMER, NO_ROLE. If NO_ROLE is specified, any existing role for the user will be removed.

  • username (string) – Username of the user to update the access role for.

class datarobot.models.deployment.deployment.FeatureDict
class datarobot.models.deployment.deployment.ForecastDateSettings

Forecast date settings of the deployment

Variables:
  • enabled (bool) – Is True if predictions by forecast date is enabled for this deployment. To update this setting, see update_predictions_by_forecast_date_settings()

  • column_name (str) – The column name in prediction datasets to be used as forecast date.

  • datetime_format (str) – The datetime format of the forecast date column in prediction datasets.

class datarobot.models.deployment.deployment.ChallengerModelsSettings

Challenger models settings of the deployment is a dict with the following format:

Variables:

enabled (bool) – Is True if challenger models is enabled for this deployment. To update existing ‘’challenger_models’’ settings, see update_challenger_models_settings()

class datarobot.models.deployment.deployment.SegmentAnalysisSettings
Segment analysis settings of the deployment containing two items with keys

enabled and attributes, which are further described below.

Variables:
class datarobot.models.deployment.deployment.BiasAndFairnessSettings

Bias and fairness settings of this deployment

Variables:
  • protected_features (List[str]) – A list of features to mark as protected.

  • preferable_target_value (bool) – A target value that should be treated as a positive outcome for the prediction.

  • fairness_metric_set (str) – Can be one of <datarobot.enums.FairnessMetricsSet>. A set of fairness metrics to use for calculating fairness.

  • fairness_threshold (float) – Threshold value of the fairness metric. Cannot be less than 0 or greater than 1.

class datarobot.models.deployment.deployment.ChallengerReplaySettings

Challenger replay settings of the deployment is a dict with the following format:

Variables:
  • enabled (bool) – If challenger replay is enabled. To update existing challenger_replay settings, see update_challenger_replay_settings()

  • schedule (Schedule) – The recurring schedule for the challenger replay job.

class datarobot.models.deployment.deployment.HealthSettings

Health settings of the deployment containing seven nested dicts with keys

Variables:
  • service (dict) – Service health settings.

  • data_drift (dict) – Data drift health settings.

  • accuracy (dict) – Accuracy health settings.

  • fairness (dict) – Fairness health settings.

  • custom_metrics (dict) – Custom metrics health settings.

  • predictions_timeliness (dict) – Predictions timeliness health settings.

  • actuals_timeliness (dict) – Actuals timeliness health settings.

class datarobot.models.deployment.deployment.DriftTrackingSettings
Drift tracking settings of the deployment containing two nested dicts with key

target_drift and feature_drift, which are further described below.

Variables:
  • target_drift (Settings) – If target drift tracking is enabled for this deployment. To create or update existing target_drift settings, see update_drift_tracking_settings()

  • feature_drift (Settings) – If feature drift tracking is enabled for this deployment. To create or update existing feature_drift settings, see update_drift_tracking_settings()

class datarobot.models.deployment.deployment.PredictionWarningSettings

Prediction warning settings of the deployment

Variables:
  • enabled (bool) – If target prediction_warning is enabled for this deployment. To create or update existing ‘’prediction_warning’’ settings, see update_prediction_warning_settings()

  • custom_boundaries (dict or None) – If None default boundaries for a model are used. Otherwise has following keys: upper (float): All predictions greater than provided value are considered anomalous lower (float): All predictions less than provided value are considered anomalous

class datarobot.models.deployment.deployment.PredictionIntervalsSettings

Prediction intervals settings of the deployment is a dict with the following format:

Variables:
  • enabled (bool) – Whether prediction intervals are enabled for this deployment

  • percentiles (list[int]) – List of enabled prediction intervals’ sizes for this deployment. Currently we only support one percentile at a time.

class datarobot.models.deployment.deployment.Capability
class datarobot.enums.ACCURACY_METRIC