Hello,
Is it possible to know prediction explanation menu's specific impact numer?
What I can only see is '+++' or '---'.
I know the impact figure is decided by SHAP or XEMP.
How to calculate the impact and can I see the specific results number like 3.45 even by using API?
Thank you.
Solved! Go to Solution.
Thank you for specific answer!
Where can I see the strength in MLOps GUI?
While it doesn't show in the GUI, if you deploy the model and make prediction in the Deployment Environment (MLOps) then the strength of the prediction will be included in the prediction explanation. Another way is throught Python API
Here is an example of prediction explanation with strength included. The result was obtained through calling the deployed model in MLOps
#Here is an example scoring through a deployed model. You will notice that I have set 'maxExplanations': 3
#Note: I'm scoring at time-series dataset
def make_datarobot_deployment_predictions(
data,
deployment_id,
forecast_point=None,
predictions_start_date=None,
predictions_end_date=None,
):
"""
Make predictions on data provided using DataRobot deployment_id provided.
See docs for details:
https://app.datarobot.com/docs/predictions/api/dr-predapi.html
Parameters
----------
data : str
Feature1,Feature2
numeric_value,string
deployment_id : str
Deployment ID to make predictions with.
forecast_point : str, optional
Forecast point as timestamp in ISO format
predictions_start_date : str, optional
Start of predictions as timestamp in ISO format
predictions_end_date : str, optional
End of predictions as timestamp in ISO format
Returns
-------
Response schema:
https://app.datarobot.com/docs/predictions/api/dr-predapi.html#response-schema
Raises
------
DataRobotPredictionError if there are issues getting predictions from DataRobot
"""
# Set HTTP headers. The charset should match the contents of the file.
headers = {
'Content-Type': 'text/plain; charset=UTF-8',
'Authorization': 'Bearer {}'.format(API_KEY),
'DataRobot-Key': DATAROBOT_KEY,
}
url = API_URL.format(deployment_id=deployment_id)
# Prediction Explanations:
# See the documentation for more information:
# https://app.datarobot.com/docs/predictions/api/dr-predapi.html#request-pred-explanations
# Should you wish to include Prediction Explanations or Prediction Warnings in the result,
# Change the parameters below accordingly, and remove the comment from the params field below:
params = {
'forecastPoint': forecast_point,
'predictionsStartDate': predictions_start_date,
'predictionsEndDate': predictions_end_date,
# If explanations are required, uncomment the line below
'maxExplanations': 3,
# 'thresholdHigh': 0.5,
# 'thresholdLow': 0.15,
# Uncomment this for Prediction Warnings, if enabled for your deployment.
# 'predictionWarningEnabled': 'true',
}
# Make API request for predictions
predictions_response = requests.post(url, data=data, headers=headers, params=params)
_raise_dataroboterror_for_status(predictions_response)
# Return a Python dict following the schema in the documentation
return predictions_response.json()
def _raise_dataroboterror_for_status(response):
"""Raise DataRobotPredictionError if the request fails along with the response returned"""
try:
response.raise_for_status()
except requests.exceptions.HTTPError:
err_msg = '{code} Error: {msg}'.format(
code=response.status_code, msg=response.text)
raise DataRobotPredictionError(err_msg)