Deployment Management¶
Deployments¶
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. - urlOptional[str]
Prediction server URL. - datarobot-keystr
Corresponds the to thePredictionServer
“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
- id (
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.
- model_id (
- 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.
- model_id (
- 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.
- custom_model_version_id (
- 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.
- model_package_id (
- 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. SeeDeploymentListFilters
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
orfile 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. Seedatarobot.models.BatchPredictionJob.score()
. - download_read_timeout (
Optional[int]
) – Wait this many seconds for the server to respond between chunks. Seedatarobot.models.BatchPredictionJob.score()
. - upload_read_timeout (
Optional[int]
) – Wait this many seconds for the server to respond after a whole dataset upload. Seedatarobot.models.BatchPredictionJob.score()
.
- source (
- 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.
- new_model_id (
- 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
- new_registered_model_version_id (
- 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.
- new_model_id (
- 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, usereplace_model()
to perform a model replacement. If the status is failing, refer tochecks
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
- status (
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 namefeature_type
: str, feature typeimportance
: 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
orpandas.DataFrame
) - batch_size (
the max number
ofactuals 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.
- data (
- 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.
- dataset_id (
- 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 toTrue
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
- enable_predictions_by_forecast_date (
- 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 toTrue
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
- challenger_models_enabled (
- 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 toTrue
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
- segment_analysis_enabled (
- 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. 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
- protected_features (
- 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.
- enabled (
- 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
- target_drift_enabled (
- 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
- column_names (
- 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 –
- enabled (bool)
: If predictions data collection is enabled for this deployment. To update
existing ‘’predictions_data_collection’’ settings, see
update_predictions_data_collection_settings()
- enabled (bool)
: If predictions data collection is enabled for this deployment. To update
existing ‘’predictions_data_collection’’ settings, see
- 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
- enabled (
- 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
- prediction_warning_enabled (
- 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
toTrue)
) – 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
- percentiles (
- 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
- AssertionError – If
- 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.
- service (
- 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
- model_id (
- 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
- metric (
- 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
- model_id (
- 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
- model_id (
- 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
- model_ids (
- 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
- model_id (
- 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
- metric (
- 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
- model_ids (
- 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.
- model_id (
- 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
orNone
) – List of DatasetsCredentials used by the secondary datasets
- secondary_dataset_config_id (
- 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
- model_id (
- 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
- filepath (
- 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
- filepath (
- 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.
- filepath (
- 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
- model_id (
- 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.
- id (
- 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.
- model_id (
- 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.
- status (
- 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).
- start (
- 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.
- segment_attribute (
- 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.
- limit (
- 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=
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.
- retraining_user_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
- data (
- 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¶
Construct a set of filters to pass to Deployment.list()
Added in version v2.20.
- Parameters:
- role (
str
) – A user role. If specified, then take those deployments that the user can view, then filter them down to those that the user has the specified role for, and return only them. Allowed options areOWNER
andUSER
. - service_health (
List[str]
) – A list of service health status values. If specified, then only deployments whose service health status is one of these will be returned. Seedatarobot.enums.DEPLOYMENT_SERVICE_HEALTH_STATUS
for allowed values. Supports comma-separated lists. - model_health (
List[str]
) – A list of model health status values. If specified, then only deployments whose model health status is one of these will be returned. Seedatarobot.enums.DEPLOYMENT_MODEL_HEALTH_STATUS
for allowed values. Supports comma-separated lists. - accuracy_health (
List[str]
) – A list of accuracy health status values. If specified, then only deployments whose accuracy health status is one of these will be returned. Seedatarobot.enums.DEPLOYMENT_ACCURACY_HEALTH_STATUS
for allowed values. Supports comma-separated lists. - execution_environment_type (
List[str]
) – A list of strings representing the type of the deployments’ execution environment. If provided, then only return those deployments whose execution environment type is one of those provided. Seedatarobot.enums.DEPLOYMENT_EXECUTION_ENVIRONMENT_TYPE
for allowed values. Supports comma-separated lists. - importance (
List[str]
) – A list of strings representing the deployments’ “importance”. If provided, then only return those deployments whose importance is one of those provided. Seedatarobot.enums.DEPLOYMENT_IMPORTANCE
for allowed values. Supports comma-separated lists. Note that Approval Workflows must be enabled for your account to use this filter, otherwise the API will return a 403.
- role (
Examples
Multiple filters can be combined in interesting ways to return very specific subsets of deployments.
Performing AND logic
Providing multiple different parameters will result in AND logic between them. For example, the following will return all deployments that I own whose service health status is failing.
from datarobot import Deployment from datarobot.models.deployment import DeploymentListFilters from datarobot.enums import DEPLOYMENT_SERVICE_HEALTH_STATUS filters = DeploymentListFilters( role='OWNER', service_health=[DEPLOYMENT_SERVICE_HEALTH.FAILING] ) deployments = Deployment.list(filters=filters)
Performing OR logic
Some filters support comma-separated lists (and will say so if they do). Providing a comma-separated list of values to a single filter performs OR logic between those values. For example, the following will return all deployments whose service health is either
warning
ORfailing
.from datarobot import Deployment from datarobot.models.deployment import DeploymentListFilters from datarobot.enums import DEPLOYMENT_SERVICE_HEALTH_STATUS filters = DeploymentListFilters( service_health=[ DEPLOYMENT_SERVICE_HEALTH.WARNING, DEPLOYMENT_SERVICE_HEALTH.FAILING, ] ) deployments = Deployment.list(filters=filters)
Performing OR logic across different filter types is not supported.
Notes
In all cases, you may only retrieve deployments for which you have at least the USER role for. Deployments for which you are a CONSUMER of will not be returned, regardless of the filters applied.
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
- model_id (
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
- deployment_id (
- 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
- model_id (
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
- deployment_id (
- 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
- model_id (
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
- deployment_id (
- 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
- model_id (
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
- deployment_id (
- 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
- baselines (
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
- deployment_id (
- 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
- model_id (
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
- deployment_id (
- 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
- model_id (
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
- deployment_id (
- 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
- deployment_id (
- 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
- summary (
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
- deployment_id (
- 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
- buckets (
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
- deployment_id (
- 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.
- share_recipient_type (
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.
- share_recipient_type (
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.
- role (
class datarobot.models.deployment.deployment.FeatureDict¶
class datarobot.models.deployment.deployment.ForecastDateSettings¶
Forecast date settings of the deployment
- Variables:
- enabled (
bool
) – IsTrue
if predictions by forecast date is enabled for this deployment. To update this setting, seeupdate_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.
- enabled (
class datarobot.models.deployment.deployment.ChallengerModelsSettings¶
Challenger models settings of the deployment is a dict with the following format:
- Variables:
enabled (
bool
) – IsTrue
if challenger models is enabled for this deployment. To update existing ‘’challenger_models’’ settings, seeupdate_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:
- enabled (
bool
) – Set toTrue
if segment analysis is enabled for this deployment. To update existing setting, seeupdate_segment_analysis_settings()
- attributes (
list
) – To create or update existing segment analysis attributes, seeupdate_segment_analysis_settings()
- enabled (
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. 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.
- protected_features (
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 existingchallenger_replay
settings, seeupdate_challenger_replay_settings()
- schedule (
Schedule
) – The recurring schedule for the challenger replay job.
- enabled (
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.
- service (
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 existingtarget_drift
settings, seeupdate_drift_tracking_settings()
- feature_drift (
Settings
) – If feature drift tracking is enabled for this deployment. To create or update existingfeature_drift
settings, seeupdate_drift_tracking_settings()
- target_drift (
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, seeupdate_prediction_warning_settings()
- custom_boundaries (
dict
orNone
) – 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
- enabled (
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.
- enabled (
class datarobot.models.deployment.deployment.Capability¶
class datarobot.enums.ACCURACY_METRIC¶
Predictions¶
class datarobot.models.Predictions¶
Represents predictions metadata and provides access to prediction results.
- Variables:
- project_id (
str
) – id of the project the model belongs to - model_id (
str
) – id of the model - prediction_id (
str
) – id of generated predictions - includes_prediction_intervals (
Optional[bool]
) – (New in v2.16) For time series projects only. Indicates if prediction intervals will be part of the response. Defaults to False. - prediction_intervals_size (
Optional[int]
) – (New in v2.16) For time series projects only. Indicates the percentile used for prediction intervals calculation. Will be present only if includes_prediction_intervals is True. - forecast_point (
datetime.datetime
, optional) – (New in v2.20) For time series projects only. This is the default point relative to which predictions will be generated, based on the forecast window of the project. See the time series prediction documentation for more information. - predictions_start_date (
datetime.datetime
orNone
, optional) – (New in v2.20) For time series projects only. The start date for bulk predictions. Note that this parameter is for generating historical predictions using the training data. This parameter should be provided in conjunction withpredictions_end_date
. Can’t be provided with theforecast_point
parameter. - predictions_end_date (
datetime.datetime
orNone
, optional) – (New in v2.20) For time series projects only. The end date for bulk predictions, exclusive. Note that this parameter is for generating historical predictions using the training data. This parameter should be provided in conjunction withpredictions_start_date
. Can’t be provided with theforecast_point
parameter. - actual_value_column (
string
, optional) – (New in version v2.21) For time series unsupervised projects only. Actual value column which was used to calculate the classification metrics and insights on the prediction dataset. Can’t be provided with theforecast_point
parameter. - explanation_algorithm (
datarobot.enums.EXPLANATIONS_ALGORITHM
, optional) – (New in version v2.21) If set to ‘shap’, the response will include prediction explanations based on the SHAP explainer (SHapley Additive exPlanations). Defaults to null (no prediction explanations). - max_explanations (
Optional[int]
) – (New in version v2.21) The maximum number of explanation values that should be returned for each row, ordered by absolute value, greatest to least. If null, no limit. In the case of ‘shap’: if the number of features is greater than the limit, the sum of remaining values will also be returned as shapRemainingTotal. Defaults to null. Cannot be set if explanation_algorithm is omitted. - shap_warnings (
dict
, optional) – (New in version v2.21) Will be present if explanation_algorithm was set to datarobot.enums.EXPLANATIONS_ALGORITHM.SHAP and there were additivity failures during SHAP values calculation.
- project_id (
Examples
List all predictions for a project
import datarobot as dr
# Fetch all predictions for a project
all_predictions = dr.Predictions.list(project_id)
# Inspect all calculated predictions
for predictions in all_predictions:
print(predictions) # repr includes project_id, model_id, and dataset_id
Retrieve predictions by id
import datarobot as dr
# Getting predictions by id
predictions = dr.Predictions.get(project_id, prediction_id)
# Dump actual predictions
df = predictions.get_all_as_dataframe()
print(df)
classmethod list(project_id, model_id=None, dataset_id=None)¶
Fetch all the computed predictions metadata for a project.
- Parameters:
- project_id (
str
) – id of the project - model_id (
Optional[str]
) – if specified, only predictions metadata for this model will be retrieved - dataset_id (
Optional[str]
) – if specified, only predictions metadata for this dataset will be retrieved
- project_id (
- Return type:
A list
ofPredictions
objects
classmethod get(project_id, prediction_id)¶
Retrieve the specific predictions metadata
- Parameters:
- project_id (
str
) – id of the project the model belongs to - prediction_id (
str
) – id of the prediction set
- project_id (
- Return type:
Predictions
- Returns:
Predictions
object representing specifiedpredictions
get_all_as_dataframe(class_prefix='class_', serializer='json')¶
Retrieve all prediction rows and return them as a pandas.DataFrame.
- Parameters:
- class_prefix (
Optional[str]
) – The prefix to append to labels in the final dataframe. Default isclass_
(e.g., apple -> class_apple) - serializer (
Optional[str]
) – Serializer to use for the download. Options:json
(default) orcsv
.
- class_prefix (
- Returns: dataframe
- Return type:
pandas.DataFrame
- Raises:
- datarobot.errors.ClientError – if the server responded with 4xx status.
- datarobot.errors.ServerError – if the server responded with 5xx status.
download_to_csv(filename, encoding='utf-8', serializer='json')¶
Save prediction rows into CSV file.
- Parameters:
- filename (
str
orfile object
) – path or file object to save prediction rows - encoding (
string
, optional) – A string representing the encoding to use in the output file, defaults to ‘utf-8’ - serializer (
Optional[str]
) – Serializer to use for the download. Options:json
(default) orcsv
.
- filename (
- Return type:
None
PredictionServer¶
class datarobot.PredictionServer¶
A prediction server can be used to make predictions.
- Variables:
- id (
Optional[str]
) – The id of the prediction server. - url (
str
) – The url of the prediction server. - datarobot_key (
Optional[str]
) – TheDatarobot-Key
HTTP header used in requests to this prediction server. Note that in thedatarobot.models.Deployment
instance there is thedefault_prediction_server
property which has this value as a “kebab-cased” key as opposed to “snake_cased”.
- id (
classmethod list()¶
Returns a list of prediction servers a user can use to make predictions.
Added in version v2.17.
- Returns: prediction_servers – Contains a list of prediction servers that can be used to make predictions.
- Return type:
list
ofPredictionServer instances
Examples
prediction_servers = PredictionServer.list()
prediction_servers
>>> [PredictionServer('https://example.com')]
Prediction environment¶
class datarobot.models.PredictionEnvironment¶
A prediction environment entity.
Added in version v3.3.0.
- Variables:
- id (
str
) – The ID of the prediction environment. - name (
str
) – The name of the prediction environment. - description (
Optional[str]
) – The description of the prediction environment. - platform (
Optional[str]
) – Indicates which platform is in use (AWS, GCP, DataRobot, etc.). - permissions (
Optional[List]
) – A set of permissions for the prediction environment. - is_deleted (
boolean
, optional) – The flag that shows if this prediction environment deleted. - supported_model_formats (
list[PredictionEnvironmentModelFormats]
, optional) – The list of supported model formats. - is_managed_by_management_agent (
boolean
, optional) – Determines if the prediction environment should be managed by the management agent. False by default. - datastore_id (
Optional[str]
) – The ID of the data store connection configuration. Only applicable for external prediction environments managed by DataRobot. - credential_id (
Optional[str]
) – The ID of the credential associated with the data connection. Only applicable for external prediction environments managed by DataRobot.
- id (
classmethod list()¶
Returns list of available external prediction environments.
- Returns: prediction_environments – contains a list of available prediction environments.
- Return type:
list
ofPredictionEnvironment instances
Examples
>>> import datarobot as dr
>>> prediction_environments = dr.PredictionEnvironment.list()
>>> prediction_environments
[
PredictionEnvironment('5e429d6ecf8a5f36c5693e03', 'demo_pe', 'aws', 'env for demo testing'),
PredictionEnvironment('5e42cc4dcf8a5f3256865840', 'azure_pe', 'azure', 'env for azure demo testing'),
]
classmethod get(pe_id)¶
Gets the PredictionEnvironment by id.
- Parameters:
pe_id (
str
) – the identifier of the PredictionEnvironment. - Returns: prediction_environment – the requested prediction environment object.
- Return type:
PredictionEnvironment
Examples
>>> import datarobot as dr
>>> pe = dr.PredictionEnvironment.get('5a8ac9ab07a57a1231be501f')
>>> pe
PredictionEnvironment('5a8ac9ab07a57a1231be501f', 'my_predict_env', 'aws', 'demo env'),
delete()¶
Deletes the prediction environment.
:rtype: None
Examples
>>> import datarobot as dr
>>> pe = dr.PredictionEnvironment.get('5a8ac9ab07a57a1231be501f')
>>> pe.delete()
classmethod create(name, platform, description=None, plugin=None, supported_model_formats=None, is_managed_by_management_agent=False, datastore=None, credential=None)¶
Create a prediction environment.
- Parameters:
- name (
str
) – The name of the prediction environment. - description (
Optional[str]
) – The description of the prediction environment. - platform (
str
) – Indicates which platform is in use (AWS, GCP, DataRobot, etc.). - plugin (
str
) – Optional. The plugin name to use. - supported_model_formats (
list[PredictionEnvironmentModelFormats]
, optional) – The list of supported model formats. When not provided, the default value is inferred based on platform, (DataRobot platform: DataRobot, Custom Models; All other platforms: DataRobot, Custom Models, External Models). - is_managed_by_management_agent (
boolean
, optional) – Determines if this prediction environment should be managed by the management agent. default: False - datastore (
DataStore|Optional[str]]
) – The datastore object or ID of the data store connection configuration. Only applicable for external Prediction Environments managed by DataRobot. - credential (
Credential|Optional[str]]
) – The credential object or ID of the credential associated with the data connection. Only applicable for external Prediction Environments managed by DataRobot.
- name (
- Returns: prediction_environment – the prediction environment was created
- Return type:
PredictionEnvironment
- Raises:
- datarobot.errors.ClientError – If the server responded with 4xx status.
- datarobot.errors.ServerError – If the server responded with 5xx status.
Examples
>>> import datarobot as dr
>>> pe = dr.PredictionEnvironment.create(
... name='my_predict_env',
... platform=PredictionEnvironmentPlatform.AWS,
... description='demo prediction env',
... )
>>> pe
PredictionEnvironment('5e429d6ecf8a5f36c5693e99', 'my_predict_env', 'aws', 'demo prediction env'),