|
|
|
|
|
prediction_schema = { |
|
"$defs": { |
|
"Result": { |
|
"description": "A single result", |
|
"properties": { |
|
"id": { |
|
"description": "The sample id", |
|
"title": "Id", |
|
"type": "integer" |
|
}, |
|
"prediction": { |
|
"description": "The prediction of the sample.", |
|
"title": "Prediction", |
|
"type": "string" |
|
} |
|
}, |
|
"required": [ |
|
"id", |
|
"prediction" |
|
], |
|
"title": "Result", |
|
"type": "object" |
|
} |
|
}, |
|
"description": "A List of task classification results", |
|
"properties": { |
|
"results": { |
|
"description": "Each item contain the id and the prediction of the sample", |
|
"items": { |
|
"$ref": "#/$defs/Result" |
|
}, |
|
"title": "Results", |
|
"type": "array" |
|
} |
|
}, |
|
"required": [ |
|
"results" |
|
], |
|
"title": "Results_List", |
|
"type": "object" |
|
} |
|
|
|
|
|
def update_classification_prediction_schema(schema, label_schema:list)->dict: |
|
""" |
|
Updates the classification prediction schema with the label schema from the yaml file |
|
:param yaml_data: The yaml data |
|
""" |
|
|
|
schema['$defs']['Result']['properties']['prediction']['enum'] = label_schema |
|
schema['$defs']['Result']['properties']['prediction'][ |
|
'description'] += 'The answer must be one of the following options: {} !!'.format(label_schema) |
|
return schema |