Skip to content

Commit

Permalink
fix(#1575): show predicted ok/ko in Text Classifier explore mode (#1576)
Browse files Browse the repository at this point in the history
This PR shows predicted ok/ko in Text Classifier explore mode for single label datasets

by @leiyre
  • Loading branch information
leiyre authored and frascuchon committed Jul 8, 2022
1 parent 0b04bc8 commit ada87c0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
4 changes: 0 additions & 4 deletions frontend/models/Common.js
Expand Up @@ -20,17 +20,14 @@ class BaseRecord {
metadata;
prediction;
annotation;
predicted;
status;
selected;
event_timestamp;

constructor({
id,
metadata,
prediction,
annotation,
predicted,
status,
selected,
event_timestamp,
Expand All @@ -40,7 +37,6 @@ class BaseRecord {
this.metadata = metadata;
this.prediction = prediction;
this.annotation = annotation;
this.predicted = predicted;
this.status = status;
this.selected = selected || false;
this.event_timestamp = event_timestamp;
Expand Down
18 changes: 18 additions & 0 deletions frontend/models/TextClassification.js
Expand Up @@ -43,6 +43,24 @@ class TextClassificationRecord extends BaseRecord {
}
return [this.prediction.labels[0].class];
}

get annotated_as() {
if (this.annotation === undefined) {
return [];
}
let labels = this.annotation.labels;
if (this.multi_label) {
return labels.map((l) => l.class);
}
return [this.annotation.labels[0].class];
}

get predicted() {
if (!this.multi_label && this.predicted_as && this.annotated_as) {
return this.predicted_as[0] === this.annotated_as[0] ? "ok" : "ko";
}
return undefined;
}
}

class TextClassificationSearchQuery extends BaseSearchQuery {
Expand Down

0 comments on commit ada87c0

Please sign in to comment.