我将 AutoML 生成的二元分类模型部署到批处理端点。我可以使用以下代码成功调用模型来输出包含二进制预测 (1|0) 的文件。
# Input being ADLS
input = Input(
type=AssetTypes.URI_FOLDER,
path="https://mydatalake.blob.core.windows.net/my_container/folder_with_data"
)
# Invoke the end point
job = ml_client.batch_endpoints.invoke(
endpoint_name=endpoint.name,
inputs={
"heart_dataset": input,
}
)
我正在尝试合并全局参数
predict_proba
,以便返回的文件包含其中一个或两个类的预测概率,但是我没有成功。例如,以下命令返回序列化错误:
# Input being ADLS
input = Input(
type=AssetTypes.URI_FOLDER,
path="https://mydatalake.blob.core.windows.net/my_container/folder_with_data"
)
# Invoke endpoint
job = ml_client.batch_endpoints.invoke(
endpoint_name="heart-test",
inputs={
"GlobalParameters": {
"method": "predict_proba"
},
"inputs": {
"heart_dataset": input
}
}
)
错误:
SerializationError:(“对象字典中的属性 None 无法序列化。 {'method': 'predict_proba'}, AttributeError: 'dict' 对象没有属性 '_attribute_map'", AttributeError("'dict' 对象没有属性 '_attribute_map'"))
我尝试了 GlobalParameters 方法 Predict_proba 的各种放置,询问法学硕士并在谷歌上搜索解决方案,试图使它们适应我的用例。
这包括上述无效代码的变体,以及利用调用方法中的模式参数(这有效但导致了二进制预测响应)。
供参考:
output_schema = {
"output_data": {
"definitions": {
"scored_data": {
"type": "array",
"items": {
"type": "object",
"properties": {
# Replace with actual class labels from your model
"Class_0": {"type": "number"},
"Class_1": {"type": "number"},
# Add additional classes as needed
}
}
}
}
}
}
# Invoke the endpoint with the output schema
job = ml_client.batch_endpoints.invoke(
endpoint_name=endpoint_name,
inputs={"heart_dataset": input},
schema=output_schema
)
由于这是部署到批处理端点的 AutoML 生成模型,因此评分脚本是自动生成的,因此我希望避免对其进行编辑,并仅使用端点调用的输入来实现返回的预测概率。
希望这是所有必需的信息,如果需要,很乐意添加更多信息。预先感谢。
对于将来发现这一点的任何人,我最终创建了一个基本的评分脚本和自定义环境(基于模型训练运行的环境)。