dataset_from_path = project.upload_dataset(scenario3_df)
model.get_or_request_feature_impact()
pei = dr.PredictionExplanationsInitialization.create(project_id, model_id)
#Wait for results of Prediction Explanations
pei.get_result_when_complete()
pe_job = dr.PredictionExplanations.create(project_id, model_id, dataset_from_path.id)
#Waiting for Job to Complete
pe = pe_job.get_result_when_complete()
df_pe = pe.get_all_as_dataframe()
In spite of using this code with no issue to get Prediction Explanation, and making sure not to use model trained on all the data, I'm now getting the following error
ClientError: 422 client error: {'message': 'Predictions must first be generated for this dataset'}
I know, from reading community threads, someone had this same issue, but the solution required DataRobot engineers.
Any help will be appreciated
Solved! Go to Solution.
You also will have to do model.request_predictions before your request for Prediction Explanations. I think you can update your script as follows:
# existing script ...
pei.get_results_when_complete()
predict_job = model.request_predictions(dataset_from_path.id predict_job.wait_for_completion()
pe_job = dr.PredictionExplanations.create(project_id, model_id, dataset_from_path.id)
# existing script ...
Here's a link to some more example scripts in the docs: https://datarobot-public-api-client.readthedocs-hosted.com/en/latest-release/reference/modeling/insi...
You also will have to do model.request_predictions before your request for Prediction Explanations. I think you can update your script as follows:
# existing script ...
pei.get_results_when_complete()
predict_job = model.request_predictions(dataset_from_path.id predict_job.wait_for_completion()
pe_job = dr.PredictionExplanations.create(project_id, model_id, dataset_from_path.id)
# existing script ...
Here's a link to some more example scripts in the docs: https://datarobot-public-api-client.readthedocs-hosted.com/en/latest-release/reference/modeling/insi...
Thank You!