我正在和使用GCP中顶点表格自动训练的模型一起工作。训练和批量预测很好。我试图在可视化中使用特性的重要性,并试图从python内部获得它们。我可以使用代码@Ricco D为我发布的代码进行模型评估:
api_endpoint = 'us-central1-aiplatform.googleapis.com'
client_options = {"api_endpoint": api_endpoint} # api_endpoint is required for client_options
client_model = aiplatform.services.model_service.ModelServiceClient(client_options=client_options)
project_id = 't...1'
location = 'us-central1'
model_id = '6...2'
model_name = f'projects/{project_id}/locations/{location}/models/{model_id}'
list_eval_request = aiplatform.types.ListModelEvaluationsRequest(parent=model_name)
list_eval = client_model.list_model_evaluations(request=list_eval_request)
for val in list_eval:
print(val.model_explanation)但是,我想不出如何获得在训练过程中产生的训练模型的特征重要性。我可以在模型页面上看到它们,但无法从python访问它们:

返回的代码ListModelEvaluationsPager对象如下:
name: "projects/7...3/locations/us-central1/models/6...2/evaluations/5...0"
metrics_schema_uri: "gs://google-cloud-aiplatform/schema/modelevaluation/regression_metrics_1.0.0.yaml"
metrics {
struct_value {
fields {
key: "meanAbsoluteError"
value {
number_value: 27.391115
}
}
fields {
key: "meanAbsolutePercentageError"
value {
number_value: 25.082605
}
}
fields {
key: "rSquared"
value {
number_value: 0.88434035
}
}
fields {
key: "rootMeanSquaredError"
value {
number_value: 47.997845
}
}
fields {
key: "rootMeanSquaredLogError"
value {
number_value: nan
}
}
}
}
create_time {
seconds: 1630550819
nanos: 842478000
}
}
>```
This object does not have a model_explanation member and the code returns an error发布于 2021-09-21 14:53:11
里科D在这里发布了一个代码解决方案来回答这个问题,Ricco D的正确答案
发布于 2021-09-20 14:22:16
特征属性包括在顶点AI预测通过顶点可解释AI。
对于批处理预测,需要在python 解释类中将True设置为文档,如下面的示例中的文档所示
注意,在云存储或预测模型中返回预测数据时,不支持特性重要性。
batch_prediction_job = {
"display_name": display_name,
# Format: 'projects/{project}/locations/{location}/models/{model_id}'
"model": model_name,
"model_parameters": model_parameters,
"input_config": {
"instances_format": instances_format,
"bigquery_source": {"input_uri": bigquery_source_input_uri},
},
"output_config": {
"predictions_format": predictions_format,
"bigquery_destination": {"output_uri": bigquery_destination_output_uri},
},
# optional
"generate_explanation": True,https://stackoverflow.com/questions/69226029
复制相似问题