Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Completes OPEN-3870 Allow specification of a prediction threshold for…
… binary classifiers
  • Loading branch information
gustavocidornelas committed Mar 15, 2023
commit c5bf3be511a27700c8e76fe58e1a1488aa760b03
17 changes: 17 additions & 0 deletions openlayer/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,23 @@ class ModelSchema(ma.Schema):
),
required=True,
)
predictionThreshold = ma.fields.Float(
allow_none=True,
validate=ma.validate.Range(
min=0.0,
max=1.0,
),
load_default=None,
)

@ma.validates_schema
def validates_prediction_threshold_and_class_names(self, data, **kwargs):
"""Validates whether a prediction threshold was specified for a
binary classification model."""
if data["predictionThreshold"] and len(data["classNames"]) != 2:
raise ma.ValidationError(
"`predictionThreshold` can only be specified for binary classification models."
)


class ProjectSchema(ma.Schema):
Expand Down